From: Joe Perches <joe@perches.com>
To: Nicholas Mc Guire <hofrat@osadl.org>,
Larry Finger <Larry.Finger@lwfinger.net>
Cc: Florian Schilhabel <florian.c.schilhabel@googlemail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Luis de Bethencourt <luisbg@osg.samsung.com>,
Gamze POLAT <gamzepolat94@gmail.com>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: rtl8712: consolidate kmalloc/memset 0 of array to kcalloc
Date: Mon, 04 Jan 2016 08:19:29 -0800 [thread overview]
Message-ID: <1451924369.4334.88.camel@perches.com> (raw)
In-Reply-To: <1451898349-5388-1-git-send-email-hofrat@osadl.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 <hofrat@osadl.org>
> ---
> 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) &
prev parent reply other threads:[~2016-01-04 16:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-04 9:05 Nicholas Mc Guire
2016-01-04 16:19 ` Joe Perches [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1451924369.4334.88.camel@perches.com \
--to=joe@perches.com \
--cc=Larry.Finger@lwfinger.net \
--cc=devel@driverdev.osuosl.org \
--cc=florian.c.schilhabel@googlemail.com \
--cc=gamzepolat94@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hofrat@osadl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luisbg@osg.samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome