From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757489AbcAOKhR (ORCPT ); Fri, 15 Jan 2016 05:37:17 -0500 Received: from smtprelay0137.hostedemail.com ([216.40.44.137]:59401 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755175AbcAOKhN (ORCPT ); Fri, 15 Jan 2016 05:37:13 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::,RULES_HIT:41:355:379:541:599:966:988:989:1042:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1540:1593:1594:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3867:3868:3870:3871:4321:4385:5007:6119:6261:7903:10004:10400:10471:10848:11026:11232:11473:11658:11783:11914:12043:12114:12438:12517:12519:12679:12740:13069:13255:13311:13357:13894:14659:21080:21212:30054:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: alley55_21a223c1dba3a X-Filterd-Recvd-Size: 2061 Message-ID: <1452854229.8586.48.camel@perches.com> Subject: Re: [PATCH v3 1/3] gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection From: Joe Perches To: SF Markus Elfring , netdev@vger.kernel.org, Claudiu Manoil Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall Date: Fri, 15 Jan 2016 02:37:09 -0800 In-Reply-To: <5698C5CB.80305@users.sourceforge.net> References: <566ABCD9.1060404@users.sourceforge.net> <56866E7F.8080609@users.sourceforge.net> <5698C53C.8060204@users.sourceforge.net> <5698C5CB.80305@users.sourceforge.net> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.3-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2016-01-15 at 11:11 +0100, SF Markus Elfring wrote: > The kfree() function was called in one case by the > gfar_ethflow_to_filer_table() function during error handling > even if a passed variable contained a null pointer. > > * Return directly if a memory allocation failed at the beginning. > > * Adjust jump targets according to the Linux coding style convention. > > This issue was detected by using the Coccinelle software. Is this really better? Perhaps this particular static analysis isn't too useful. Why not just allocate once and assign a second pointer? local_rqfpr = kmalloc_array(2 * (MAX_FILER_IDX + 1),     sizeof(unsigned int), GFP_KERNEL); if (!local_rqfpr) goto err; local_rqfcr = &local_rqfpr[MAX_FILER_IDX + 1]; Perhaps this would be better removing the ret variable and using something like: int gfar_ethflow_to_filer_table(...) { ... return 0; err: kfree(local_rqfpt); return 1; } From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joe Perches Date: Fri, 15 Jan 2016 10:37:09 +0000 Subject: Re: [PATCH v3 1/3] gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detecti Message-Id: <1452854229.8586.48.camel@perches.com> List-Id: References: <566ABCD9.1060404@users.sourceforge.net> <56866E7F.8080609@users.sourceforge.net> <5698C53C.8060204@users.sourceforge.net> <5698C5CB.80305@users.sourceforge.net> In-Reply-To: <5698C5CB.80305@users.sourceforge.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: SF Markus Elfring , netdev@vger.kernel.org, Claudiu Manoil Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall On Fri, 2016-01-15 at 11:11 +0100, SF Markus Elfring wrote: > The kfree() function was called in one case by the > gfar_ethflow_to_filer_table() function during error handling > even if a passed variable contained a null pointer. >=20 > * Return directly if a memory allocation failed at the beginning. >=20 > * Adjust jump targets according to the Linux coding style convention. >=20 > This issue was detected by using the Coccinelle software. Is this really better? Perhaps this particular static analysis isn't too useful. Why not just allocate once and assign a second pointer? local_rqfpr =3D kmalloc_array(2 * (MAX_FILER_IDX + 1), =A0 =A0 sizeof(unsigned int), GFP_KERNEL); if (!local_rqfpr) goto err; local_rqfcr =3D &local_rqfpr[MAX_FILER_IDX + 1]; Perhaps this would be better removing the ret variable and using something like: int gfar_ethflow_to_filer_table(...) { ... return 0; err: kfree(local_rqfpt); return 1; } -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" = in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html