* [PATCH] staging: wlang-ng: get memory from kernel allocators instead of big static buffer
@ 2016-10-03 16:05 Sergio Paracuellos
2016-10-09 14:31 ` Greg KH
0 siblings, 1 reply; 7+ messages in thread
From: Sergio Paracuellos @ 2016-10-03 16:05 UTC (permalink / raw)
To: gregkh; +Cc: devel, linux-kernel
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)) {
+ result = -ENOMEM;
+ goto out;
+ }
+
ns3plug = 0;
memset(s3plug, 0, sizeof(s3plug));
ns3crc = 0;
@@ -475,7 +480,7 @@ static void free_chunks(struct imgchunk *fchunk, unsigned int *nfchunks)
static void free_srecs(void)
{
ns3data = 0;
- memset(s3data, 0, sizeof(s3data));
+ kfree(s3data);
ns3plug = 0;
memset(s3plug, 0, sizeof(s3plug));
ns3crc = 0;
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] staging: wlang-ng: get memory from kernel allocators instead of big static buffer
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
0 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2016-10-09 14:31 UTC (permalink / raw)
To: Sergio Paracuellos; +Cc: devel, linux-kernel
On Mon, Oct 03, 2016 at 06:05:44PM +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(-)
Subject also wrong :(
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] staging: wlan-ng: get memory from kernel allocators instead of big static buffer
2016-10-09 14:31 ` Greg KH
@ 2016-10-09 15:14 ` Sergio Paracuellos
2016-10-09 15:25 ` Greg KH
0 siblings, 1 reply; 7+ messages in thread
From: Sergio Paracuellos @ 2016-10-09 15:14 UTC (permalink / raw)
To: gregkh; +Cc: devel, linux-kernel
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)) {
+ result = -ENOMEM;
+ goto out;
+ }
+
ns3plug = 0;
memset(s3plug, 0, sizeof(s3plug));
ns3crc = 0;
@@ -475,7 +480,7 @@ static void free_chunks(struct imgchunk *fchunk, unsigned int *nfchunks)
static void free_srecs(void)
{
ns3data = 0;
- memset(s3data, 0, sizeof(s3data));
+ kfree(s3data);
ns3plug = 0;
memset(s3plug, 0, sizeof(s3plug));
ns3crc = 0;
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] staging: wlan-ng: get memory from kernel allocators instead of big static buffer
2016-10-09 15:14 ` [PATCH] staging: wlan-ng: " Sergio Paracuellos
@ 2016-10-09 15:25 ` Greg KH
2016-10-09 15:29 ` Sergio Paracuellos
0 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2016-10-09 15:25 UTC (permalink / raw)
To: Sergio Paracuellos; +Cc: devel, linux-kernel
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] staging: wlan-ng: get memory from kernel allocators instead of big static buffer
2016-10-09 15:25 ` Greg KH
@ 2016-10-09 15:29 ` Sergio Paracuellos
2016-10-09 15:36 ` Greg KH
0 siblings, 1 reply; 7+ messages in thread
From: Sergio Paracuellos @ 2016-10-09 15:29 UTC (permalink / raw)
To: gregkh; +Cc: devel, linux-kernel
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 (!s3data) {
+ result = -ENOMEM;
+ goto out;
+ }
+
ns3plug = 0;
memset(s3plug, 0, sizeof(s3plug));
ns3crc = 0;
@@ -475,7 +480,7 @@ static void free_chunks(struct imgchunk *fchunk, unsigned int *nfchunks)
static void free_srecs(void)
{
ns3data = 0;
- memset(s3data, 0, sizeof(s3data));
+ kfree(s3data);
ns3plug = 0;
memset(s3plug, 0, sizeof(s3plug));
ns3crc = 0;
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] staging: wlan-ng: get memory from kernel allocators instead of big static buffer
2016-10-09 15:29 ` Sergio Paracuellos
@ 2016-10-09 15:36 ` Greg KH
2016-10-09 15:38 ` Sergio Paracuellos
0 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2016-10-09 15:36 UTC (permalink / raw)
To: Sergio Paracuellos; +Cc: devel, linux-kernel
On Sun, Oct 09, 2016 at 05:29:22PM +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(-)
Fastest patch review turn-around time ever :)
nice work, all now applied.
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] staging: wlan-ng: get memory from kernel allocators instead of big static buffer
2016-10-09 15:36 ` Greg KH
@ 2016-10-09 15:38 ` Sergio Paracuellos
0 siblings, 0 replies; 7+ messages in thread
From: Sergio Paracuellos @ 2016-10-09 15:38 UTC (permalink / raw)
To: Greg KH; +Cc: devel, linux-kernel
Just sitting in front of my laptop :) Thanks to you for code review!
Cheers,
Sergio Paracuello
El 2016年10月09日 a las 17:36, Greg KH escribió:
> On Sun, Oct 09, 2016 at 05:29:22PM +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(-)
>
> Fastest patch review turn-around time ever :)
>
> nice work, all now applied.
>
> greg k-h
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-10-09 15:38 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2016-10-09 15:29 ` Sergio Paracuellos
2016-10-09 15:36 ` Greg KH
2016-10-09 15:38 ` Sergio Paracuellos
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).