From: Greg KH <gregkh@linuxfoundation.org>
To: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: wlan-ng: get memory from kernel allocators instead of big static buffer
Date: Sun, 9 Oct 2016 17:25:23 +0200 [thread overview]
Message-ID: <20161009152523.GA23652@kroah.com> (raw)
In-Reply-To: <1476026092-15393-1-git-send-email-sergio.paracuellos@gmail.com>
On Sun, Oct 09, 2016 at 05:14:52PM +0200, Sergio Paracuellos wrote:
> This patch fix the following sparse warnings in prism2fw.c:
> warning: memset with byte count of 120000
>
> Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
> ---
> drivers/staging/wlan-ng/prism2fw.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c
> index 96aa211..7e33048 100644
> --- a/drivers/staging/wlan-ng/prism2fw.c
> +++ b/drivers/staging/wlan-ng/prism2fw.c
> @@ -124,7 +124,7 @@ struct imgchunk {
>
> /* Data records */
> static unsigned int ns3data;
> -static struct s3datarec s3data[S3DATA_MAX];
> +static struct s3datarec *s3data;
>
> /* Plug records */
> static unsigned int ns3plug;
> @@ -248,7 +248,12 @@ static int prism2_fwapply(const struct ihex_binrec *rfptr,
>
> /* Initialize the data structures */
> ns3data = 0;
> - memset(s3data, 0, sizeof(s3data));
> + s3data = kcalloc(S3DATA_MAX, sizeof(*s3data), GFP_KERNEL);
> + if (unlikely(!s3data)) {
Unless you can measure the speed difference, NEVER use likely or
unlikely in kernel code. The CPU and compiler knows better than you do
what is going to happen, and optimizes it. Especially for allocating
memory, that is a very common pattern and it knows what to do here.
Please remove this and resend.
thanks,
greg k-h
next prev parent reply other threads:[~2016-10-09 15:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-03 16:05 [PATCH] staging: wlang-ng: get memory from kernel allocators instead of big static buffer Sergio Paracuellos
2016-10-09 14:31 ` Greg KH
2016-10-09 15:14 ` [PATCH] staging: wlan-ng: " Sergio Paracuellos
2016-10-09 15:25 ` Greg KH [this message]
2016-10-09 15:29 ` Sergio Paracuellos
2016-10-09 15:36 ` Greg KH
2016-10-09 15:38 ` Sergio Paracuellos
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=20161009152523.GA23652@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=devel@driverdev.osuosl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sergio.paracuellos@gmail.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