From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934209AbbLWKlz (ORCPT ); Wed, 23 Dec 2015 05:41:55 -0500 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:54897 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753802AbbLWKlx (ORCPT ); Wed, 23 Dec 2015 05:41:53 -0500 X-IronPort-AV: E=Sophos;i="5.20,468,1444687200"; d="scan'208";a="193727820" Date: Wed, 23 Dec 2015 11:41:47 +0100 (CET) From: Julia Lawall X-X-Sender: jll@hadrien To: SF Markus Elfring cc: linux-ntfs-dev@lists.sourceforge.net, linux-block@vger.kernel.org, Jens Axboe , Richard Russon , LKML , kernel-janitors@vger.kernel.org Subject: Re: [PATCH] block-LDM: One function call less in ldm_validate_tocblocks() after error detection In-Reply-To: <567A6CDB.4030703@users.sourceforge.net> Message-ID: References: <566ABCD9.1060404@users.sourceforge.net> <567A6CDB.4030703@users.sourceforge.net> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 23 Dec 2015, SF Markus Elfring wrote: > From: Markus Elfring > Date: Tue, 22 Dec 2015 22:32:07 +0100 > > This issue was detected by using the Coccinelle software. > > Let us return directly if a memory allocation failed. > > Signed-off-by: Markus Elfring > --- > block/partitions/ldm.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/block/partitions/ldm.c b/block/partitions/ldm.c > index e507cfb..a50385c 100644 > --- a/block/partitions/ldm.c > +++ b/block/partitions/ldm.c > @@ -433,7 +433,7 @@ static bool ldm_validate_tocblocks(struct parsed_partitions *state, > tb[1] = kmalloc(sizeof(*tb[1]) * 3, GFP_KERNEL); > if (!tb[1]) { > ldm_crit("Out of memory."); > - goto err; > + return false; The ldm_crit, which is just a printk, is also not necessary, because kmalloc already generates backtrace information on failure. So you could clean up the whole thing at once. julia > } > tb[2] = (struct tocblock*)((u8*)tb[1] + sizeof(*tb[1])); > tb[3] = (struct tocblock*)((u8*)tb[2] + sizeof(*tb[2])); > -- > 2.6.3 > > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julia Lawall Date: Wed, 23 Dec 2015 10:41:47 +0000 Subject: Re: [PATCH] block-LDM: One function call less in ldm_validate_tocblocks() after error detection Message-Id: List-Id: References: <566ABCD9.1060404@users.sourceforge.net> <567A6CDB.4030703@users.sourceforge.net> In-Reply-To: <567A6CDB.4030703@users.sourceforge.net> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: SF Markus Elfring Cc: linux-ntfs-dev@lists.sourceforge.net, linux-block@vger.kernel.org, Jens Axboe , Richard Russon , LKML , kernel-janitors@vger.kernel.org On Wed, 23 Dec 2015, SF Markus Elfring wrote: > From: Markus Elfring > Date: Tue, 22 Dec 2015 22:32:07 +0100 > > This issue was detected by using the Coccinelle software. > > Let us return directly if a memory allocation failed. > > Signed-off-by: Markus Elfring > --- > block/partitions/ldm.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/block/partitions/ldm.c b/block/partitions/ldm.c > index e507cfb..a50385c 100644 > --- a/block/partitions/ldm.c > +++ b/block/partitions/ldm.c > @@ -433,7 +433,7 @@ static bool ldm_validate_tocblocks(struct parsed_partitions *state, > tb[1] = kmalloc(sizeof(*tb[1]) * 3, GFP_KERNEL); > if (!tb[1]) { > ldm_crit("Out of memory."); > - goto err; > + return false; The ldm_crit, which is just a printk, is also not necessary, because kmalloc already generates backtrace information on failure. So you could clean up the whole thing at once. julia > } > tb[2] = (struct tocblock*)((u8*)tb[1] + sizeof(*tb[1])); > tb[3] = (struct tocblock*)((u8*)tb[2] + sizeof(*tb[2])); > -- > 2.6.3 > >