* [PATCH] staging: rtl8192e: check return value of dev_skb_alloc
@ 2014-06-19 2:24 Nicholas Krause
2014-06-19 2:45 ` Greg KH
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Nicholas Krause @ 2014-06-19 2:24 UTC (permalink / raw)
To: gregkh; +Cc: lisa, valentina.manea.m, ben, devel, linux-kernel
Checks if dev_skb_alloc returns Null in function, fw_download_code.
If the return value of dev_skb_alloc is NULL return false and exit
this function.
Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
---
drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
index 1a95d1f..38ae236 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
@@ -62,6 +62,8 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
skb = dev_alloc_skb(frag_length + 4);
memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev));
+ if (!skb)
+ return !rt_status;
tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
tcb_desc->queue_index = TXCMD_QUEUE;
tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_INIT;
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH] staging: rtl8192e: check return value of dev_skb_alloc
2014-06-19 2:24 [PATCH] staging: rtl8192e: check return value of dev_skb_alloc Nicholas Krause
@ 2014-06-19 2:45 ` Greg KH
2014-06-19 4:14 ` Joe Perches
2014-06-19 5:29 ` Dan Carpenter
2 siblings, 0 replies; 8+ messages in thread
From: Greg KH @ 2014-06-19 2:45 UTC (permalink / raw)
To: Nicholas Krause; +Cc: devel, ben, lisa, valentina.manea.m, linux-kernel
On Wed, Jun 18, 2014 at 10:24:41PM -0400, Nicholas Krause wrote:
> Checks if dev_skb_alloc returns Null in function, fw_download_code.
> If the return value of dev_skb_alloc is NULL return false and exit
> this function.
> Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
> ---
> drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
> index 1a95d1f..38ae236 100644
> --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
> +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
> @@ -62,6 +62,8 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
>
> skb = dev_alloc_skb(frag_length + 4);
> memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev));
> + if (!skb)
> + return !rt_status;
> tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
> tcb_desc->queue_index = TXCMD_QUEUE;
> tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_INIT;
As writing emails to you seems like dumping stuff into a vacuum, I'm
going to just delete this message and start ignoring your mail like you
seem to be ignoring mine...
Best of luck,
greg k-h
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] staging: rtl8192e: check return value of dev_skb_alloc
2014-06-19 2:24 [PATCH] staging: rtl8192e: check return value of dev_skb_alloc Nicholas Krause
2014-06-19 2:45 ` Greg KH
@ 2014-06-19 4:14 ` Joe Perches
2014-06-19 5:29 ` Dan Carpenter
2 siblings, 0 replies; 8+ messages in thread
From: Joe Perches @ 2014-06-19 4:14 UTC (permalink / raw)
To: Nicholas Krause; +Cc: gregkh, lisa, valentina.manea.m, ben, devel, linux-kernel
On Wed, 2014-06-18 at 22:24 -0400, Nicholas Krause wrote:
> Checks if dev_skb_alloc returns Null in function, fw_download_code.
> If the return value of dev_skb_alloc is NULL return false and exit
> this function.
Hello Nicholas.
If you're going to try add these checks, please look at
the code a bit more before submitting defective patches.
> diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
[]
> @@ -62,6 +62,8 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
>
> skb = dev_alloc_skb(frag_length + 4);
> memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev));
> + if (!skb)
> + return !rt_status;
Umm, if you're going to check whether or not skb is NULL,
do it before it's dereferenced as skb->cb.
Oh, and get rid of rt_status and use
return false;
directly.
> tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
> tcb_desc->queue_index = TXCMD_QUEUE;
> tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_INIT;
and change the end of function
from:
return rt_status;
to:
return true;
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] staging: rtl8192e: check return value of dev_skb_alloc
2014-06-19 2:24 [PATCH] staging: rtl8192e: check return value of dev_skb_alloc Nicholas Krause
2014-06-19 2:45 ` Greg KH
2014-06-19 4:14 ` Joe Perches
@ 2014-06-19 5:29 ` Dan Carpenter
2014-06-19 18:41 ` Nick Krause
2 siblings, 1 reply; 8+ messages in thread
From: Dan Carpenter @ 2014-06-19 5:29 UTC (permalink / raw)
To: Nicholas Krause; +Cc: gregkh, devel, ben, lisa, valentina.manea.m, linux-kernel
On Wed, Jun 18, 2014 at 10:24:41PM -0400, Nicholas Krause wrote:
> Checks if dev_skb_alloc returns Null in function, fw_download_code.
> If the return value of dev_skb_alloc is NULL return false and exit
> this function.
> Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
> ---
> drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
> index 1a95d1f..38ae236 100644
> --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
> +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
> @@ -62,6 +62,8 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
>
> skb = dev_alloc_skb(frag_length + 4);
> memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev));
> + if (!skb)
> + return !rt_status;
What's this !rt_status? Just return false.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] staging: rtl8192e: check return value of dev_skb_alloc
2014-06-19 5:29 ` Dan Carpenter
@ 2014-06-19 18:41 ` Nick Krause
0 siblings, 0 replies; 8+ messages in thread
From: Nick Krause @ 2014-06-19 18:41 UTC (permalink / raw)
To: Dan Carpenter; +Cc: Greg KH, devel, ben, lisa, Valentina Manea, linux-kernel
Hey guys,
Sorry about no reply,
my power supply died last night,
have to get a new one. I will be RMAing
the old old in order to get a packup in
case this PSU dies.
Cheers Nick
On Thu, Jun 19, 2014 at 1:29 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> On Wed, Jun 18, 2014 at 10:24:41PM -0400, Nicholas Krause wrote:
>> Checks if dev_skb_alloc returns Null in function, fw_download_code.
>> If the return value of dev_skb_alloc is NULL return false and exit
>> this function.
>> Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
>> ---
>> drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
>> index 1a95d1f..38ae236 100644
>> --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
>> +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
>> @@ -62,6 +62,8 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
>>
>> skb = dev_alloc_skb(frag_length + 4);
>> memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev));
>> + if (!skb)
>> + return !rt_status;
>
> What's this !rt_status? Just return false.
>
> regards,
> dan carpenter
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] staging: rtl8192e: check return value of dev_skb_alloc
@ 2014-06-19 19:29 Nicholas Krause
2014-06-19 21:25 ` Joe Perches
0 siblings, 1 reply; 8+ messages in thread
From: Nicholas Krause @ 2014-06-19 19:29 UTC (permalink / raw)
To: gregkh; +Cc: valentina.manea.m, lisa, ben, devel, linux-kernel
---
drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
index 1a95d1f..d8a9427 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
@@ -36,7 +36,6 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
u32 buffer_len)
{
struct r8192_priv *priv = rtllib_priv(dev);
- bool rt_status = true;
u16 frag_threshold;
u16 frag_length, frag_offset = 0;
int i;
@@ -59,7 +58,8 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
bLastIniPkt = 1;
}
-
+ if (!skb)
+ return false;
skb = dev_alloc_skb(frag_length + 4);
memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev));
tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
@@ -99,7 +99,7 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
write_nic_byte(dev, TPPoll, TPPoll_CQ);
- return rt_status;
+ return true;
}
static bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev)
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH] staging: rtl8192e: check return value of dev_skb_alloc
2014-06-19 19:29 Nicholas Krause
@ 2014-06-19 21:25 ` Joe Perches
2014-06-20 16:31 ` Nick Krause
0 siblings, 1 reply; 8+ messages in thread
From: Joe Perches @ 2014-06-19 21:25 UTC (permalink / raw)
To: Nicholas Krause; +Cc: gregkh, valentina.manea.m, lisa, ben, devel, linux-kernel
On Thu, 2014-06-19 at 15:29 -0400, Nicholas Krause wrote:
> diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
[]
> @@ -59,7 +58,8 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
> bLastIniPkt = 1;
>
> }
> -
> + if (!skb)
> + return false;
> skb = dev_alloc_skb(frag_length + 4);
Nick.
You may have compiled this, but it's obvious you
haven't tested it.
Please stop sending patches until you can verify what
you're doing with the code.
Please train a few more of your neurons for coding.
It takes some time and some practice but please don't
practice on linux-kernel.
Use google to find some other suitable forums like
http://cboard.cprogramming.com/c-programming/
Back to your patch:
if (!skb)
return false;
must go _after_
skb = dev_alloc_skb(frag_length + 4);
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] staging: rtl8192e: check return value of dev_skb_alloc
2014-06-19 21:25 ` Joe Perches
@ 2014-06-20 16:31 ` Nick Krause
0 siblings, 0 replies; 8+ messages in thread
From: Nick Krause @ 2014-06-20 16:31 UTC (permalink / raw)
To: Joe Perches; +Cc: Greg KH, Valentina Manea, lisa, ben, devel, linux-kernel
This patch is old I thought I fixed it and resent.
Cheers Nick
On Thu, Jun 19, 2014 at 5:25 PM, Joe Perches <joe@perches.com> wrote:
> On Thu, 2014-06-19 at 15:29 -0400, Nicholas Krause wrote:
>
>> diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
> []
>> @@ -59,7 +58,8 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
>> bLastIniPkt = 1;
>>
>> }
>> -
>> + if (!skb)
>> + return false;
>> skb = dev_alloc_skb(frag_length + 4);
>
> Nick.
>
> You may have compiled this, but it's obvious you
> haven't tested it.
>
> Please stop sending patches until you can verify what
> you're doing with the code.
>
> Please train a few more of your neurons for coding.
>
> It takes some time and some practice but please don't
> practice on linux-kernel.
>
> Use google to find some other suitable forums like
> http://cboard.cprogramming.com/c-programming/
>
> Back to your patch:
>
> if (!skb)
> return false;
>
> must go _after_
>
> skb = dev_alloc_skb(frag_length + 4);
>
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-06-20 16:31 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-19 2:24 [PATCH] staging: rtl8192e: check return value of dev_skb_alloc Nicholas Krause
2014-06-19 2:45 ` Greg KH
2014-06-19 4:14 ` Joe Perches
2014-06-19 5:29 ` Dan Carpenter
2014-06-19 18:41 ` Nick Krause
-- strict thread matches above, loose matches on Subject: below --
2014-06-19 19:29 Nicholas Krause
2014-06-19 21:25 ` Joe Perches
2014-06-20 16:31 ` Nick Krause
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox