From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752823AbcADQTi (ORCPT ); Mon, 4 Jan 2016 11:19:38 -0500 Received: from smtprelay0186.hostedemail.com ([216.40.44.186]:57947 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751904AbcADQTe (ORCPT ); Mon, 4 Jan 2016 11:19:34 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::,RULES_HIT:41:355:379:541:599:800:960:966:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2194:2196:2199:2200:2393:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3866:3867:3871:4250:4321:4385:5007:6261:7903:8603:10004:10400:10848:11026:11232:11473:11658:11783:11914:12043:12296:12438:12517:12519:12555:12740:13069:13311:13357:13894:14659:21080:21212:30012: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:11,LUA_SUMMARY:none X-HE-Tag: pain69_35e45195cb113 X-Filterd-Recvd-Size: 2822 Message-ID: <1451924369.4334.88.camel@perches.com> Subject: Re: [PATCH] staging: rtl8712: consolidate kmalloc/memset 0 of array to kcalloc From: Joe Perches To: Nicholas Mc Guire , Larry Finger Cc: Florian Schilhabel , Greg Kroah-Hartman , Luis de Bethencourt , Gamze POLAT , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Date: Mon, 04 Jan 2016 08:19:29 -0800 In-Reply-To: <1451898349-5388-1-git-send-email-hofrat@osadl.org> References: <1451898349-5388-1-git-send-email-hofrat@osadl.org> 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 Mon, 2016-01-04 at 10:05 +0100, Nicholas Mc Guire wrote: > This is an API consolidation only. The use of kmalloc of an array > of elements of equal size + memset to 0 of the same is equivalent to > kcalloc. Inequivalent code. > Signed-off-by: Nicholas Mc Guire > --- > Found by coccinelle script (relaxed version of > scripts/coccinelle/api/alloc/kzalloc-simple.cocci) > > Patch was compile tested with: x86_64_defconfig + > CONFIG_STAGING=y, CONFIG_R8712U=m > > Patch is against linux-next (localversion-next is -next-20160104) > >  drivers/staging/rtl8712/rtl871x_recv.c | 4 +--- >  1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/staging/rtl8712/rtl871x_recv.c b/drivers/staging/rtl8712/rtl871x_recv.c > index 4ff5301..aa841bf 100644 > --- a/drivers/staging/rtl8712/rtl871x_recv.c > +++ b/drivers/staging/rtl8712/rtl871x_recv.c > @@ -72,14 +72,12 @@ sint _r8712_init_recv_priv(struct recv_priv *precvpriv, >   _init_queue(&precvpriv->recv_pending_queue); >   precvpriv->adapter = padapter; >   precvpriv->free_recvframe_cnt = NR_RECVFRAME; > - precvpriv->pallocated_frame_buf = kmalloc(NR_RECVFRAME * > + precvpriv->pallocated_frame_buf = kcalloc(NR_RECVFRAME, >   sizeof(union recv_frame) + RXFRAME_ALIGN_SZ, This allocates a different size now. >   GFP_ATOMIC); >   if (precvpriv->pallocated_frame_buf == NULL) >   return _FAIL; >   kmemleak_not_leak(precvpriv->pallocated_frame_buf); > - memset(precvpriv->pallocated_frame_buf, 0, NR_RECVFRAME * > - sizeof(union recv_frame) + RXFRAME_ALIGN_SZ); >   precvpriv->precv_frame_buf = precvpriv->pallocated_frame_buf + >       RXFRAME_ALIGN_SZ - >       ((addr_t)(precvpriv->pallocated_frame_buf) &