From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932545AbcGZTQL (ORCPT ); Tue, 26 Jul 2016 15:16:11 -0400 Received: from mga09.intel.com ([134.134.136.24]:32595 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932528AbcGZTQI convert rfc822-to-8bit (ORCPT ); Tue, 26 Jul 2016 15:16:08 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,426,1464678000"; d="scan'208";a="1029590264" Subject: Re: [lustre-devel] [PATCH 05/12] staging: lustre: Optimize error handling in class_register_type() Mime-Version: 1.0 (Apple Message framework v1283) Content-Type: text/plain; charset=windows-1252 From: Oleg Drokin In-Reply-To: <3F437188-382B-46C8-9C30-7DBAB17F62E3@intel.com> Date: Tue, 26 Jul 2016 15:16:03 -0400 Cc: , Greg Kroah-Hartman , , LKML , Julia Lawall , "Bhumika Goyal" , Content-Transfer-Encoding: 8BIT Message-Id: <0F5BB200-CA27-4384-B3AE-28E30CFF42EE@intel.com> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> <56784D83.7080108@users.sourceforge.net> <56784F0C.6040007@users.sourceforge.net> <20151221234857.GA27079@kroah.com> <59d94e70-7476-728e-5f63-013557ec2db9@users.sourceforge.net> <3F437188-382B-46C8-9C30-7DBAB17F62E3@intel.com> To: SF Markus Elfring X-Mailer: Apple Mail (2.1283) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Jul 26, 2016, at 3:11 PM, Oleg Drokin wrote: > > On Jul 26, 2016, at 3:05 PM, SF Markus Elfring wrote: > >> From: Markus Elfring >> Date: Tue, 26 Jul 2016 14:23:23 +0200 >> >> Return a constant error code without storing it in the local variable "rc" >> after a failed memory allocation at the beginning of this function. >> >> Signed-off-by: Markus Elfring >> --- >> drivers/staging/lustre/lustre/obdclass/genops.c | 3 +-- >> 1 file changed, 1 insertion(+), 2 deletions(-) >> >> diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c >> index fd5e61f..4752091 100644 >> --- a/drivers/staging/lustre/lustre/obdclass/genops.c >> +++ b/drivers/staging/lustre/lustre/obdclass/genops.c >> @@ -152,10 +152,9 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, >> return -EEXIST; >> } >> >> - rc = -ENOMEM; > > NAK. > when you do this, the next statement below breaks: Ah, I see there was patch 4 before patch 5 that actually placed rc assignments everywhere. So I guess it is fine after all. Sorry for the noise. > >> type = kzalloc(sizeof(*type), GFP_NOFS); >> if (!type) >> - return rc; >> + return -ENOMEM; >> >> type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS); >> if (!type->typ_dt_ops) { > … > goto failed; > > failed: > … > return rc; > > So we are now returning an unitialized rc, did you get a gcc warning about it when compiling? > _______________________________________________ > lustre-devel mailing list > lustre-devel@lists.lustre.org > http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org