staging: Check against NULL in fw_download_code
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): CAPDOMVghgyQ72J6MS6uaWEeMFBvzDNmfoAS5Tbd7+XO_KgUmHg@mail.gmail.com
Quoted 26 lines · Nick Krause
Quoted 25 lines · Nicholas Krause
I am fixing the bug entry , https://bugzilla.kernel.org/show_bug.cgi?id=60461.
This entry states that we are not checking the skb allocated infw_download_codeand after checking I fixed it to check for the NULL value before using the allocate skb.Signed-off-by Nicholas Krause <[email protected]>--- drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c +0
-6@@ -60,13 +60,15 @@ 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)); - tcb_desc = (struct cb_desc *)(skb->cb +MAX_DEV_ADDR_SIZE ); - tcb_desc->queue_index =TXCMD_QUEUE ; - tcb_desc->bCmdOrInit =DESC_PACKET_TYPE_INIT ; - tcb_desc->bLastIniPkt = bLastIniPkt;
Quoted 8 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, · line 71
Quoted 8 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c +8
-0+ skb =dev_alloc_skb (frag_length +4 ); +if (skb) { +memcpy ((unsigned char *)(skb->cb), &dev,sizeof (dev)); + tcb_desc = (struct cb_desc *)(skb->cb +MAX_DEV_ADDR_SIZE ); + tcb_desc->queue_index =TXCMD_QUEUE ; + tcb_desc->bCmdOrInit =DESC_PACKET_TYPE_INIT ; + tcb_desc->bLastIniPkt = bLastIniPkt; + }
and what happens here (below) if skb is NULL?
Quoted 9 lines
Quoted 6 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c +0
-1seg_ptr = skb->data;for (i =0 ; i < frag_length; i +=4 ) { *seg_ptr++ = ((i+0) < frag_length) ? --1.9.1
And I did check it against Linus's tree to make sure it applies , just to let you known.
Nick
Signature · 1 line
~Randy
A message that is not in the archive (sent off-list or not yet received): CAPDOMViHWMRRMqdEpjft0TDuVSLai8LuWRcXPdMeCtUYgB2sgw@mail.gmail.com
Quoted 28 lines · Nick Krause
Quoted 27 lines · Randy Dunlap
Quoted 26 lines · Nick Krause
Quoted 25 lines · Nicholas Krause
I am fixing the bug entry , https://bugzilla.kernel.org/show_bug.cgi?id=60461.
This entry states that we are not checking the skb allocated infw_download_codeand after checking I fixed it to check for the NULL value before using the allocate skb.Signed-off-by Nicholas Krause <[email protected]>--- drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c +0
-6@@ -60,13 +60,15 @@ 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)); - tcb_desc = (struct cb_desc *)(skb->cb +MAX_DEV_ADDR_SIZE ); - tcb_desc->queue_index =TXCMD_QUEUE ; - tcb_desc->bCmdOrInit =DESC_PACKET_TYPE_INIT ; - tcb_desc->bLastIniPkt = bLastIniPkt;
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, · line 71
Quoted 8 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c +8
-0+ skb =dev_alloc_skb (frag_length +4 ); +if (skb) { +memcpy ((unsigned char *)(skb->cb), &dev,sizeof (dev)); + tcb_desc = (struct cb_desc *)(skb->cb +MAX_DEV_ADDR_SIZE ); + tcb_desc->queue_index =TXCMD_QUEUE ; + tcb_desc->bCmdOrInit =DESC_PACKET_TYPE_INIT ; + tcb_desc->bLastIniPkt = bLastIniPkt; + }and what happens here (below) if skb is NULL?
Nick,
I'm asking if you have completely fixed the bug or only partially fixed it. The answer is that the patch is only a partial fix. If skb is NULL, there is still a problem in the statement below here. The kernel will oops on that reference to skb, which is NULL.
Quoted 18 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c +0
-1seg_ptr = skb->data;for (i =0 ; i < frag_length; i +=4 ) { *seg_ptr++ = ((i+0) < frag_length) ? --1.9.1
Quoted 7 lines
Quoted 3 lines
And I did check it against Linus's tree to make sure it applies , just to let you known.
Nick--
~RandySorry Randy.
I may be mis reading this, but are you asking me to write a different
commit message or is this patch just another bad patch in my series of bad patches?
Signature · 1 line
~Randy
A message that is not in the archive (sent off-list or not yet received): CAPDOMVj0YcDc5ATxMiTLeciadJPiQxV2ap8Wo3Qg4RM=yeXmVQ@mail.gmail.com
Quoted 67 lines · Nick Krause
Quoted 66 lines · Randy Dunlap
Quoted 28 lines · Nick Krause
Quoted 27 lines · Randy Dunlap
Quoted 26 lines · Nick Krause
Quoted 25 lines · Nicholas Krause
I am fixing the bug entry , https://bugzilla.kernel.org/show_bug.cgi?id=60461.
This entry states that we are not checking the skb allocated infw_download_codeand after checking I fixed it to check for the NULL value before using the allocate skb.Signed-off-by Nicholas Krause <[email protected]>--- drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c +0
-6@@ -60,13 +60,15 @@ 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)); - tcb_desc = (struct cb_desc *)(skb->cb +MAX_DEV_ADDR_SIZE ); - tcb_desc->queue_index =TXCMD_QUEUE ; - tcb_desc->bCmdOrInit =DESC_PACKET_TYPE_INIT ; - tcb_desc->bLastIniPkt = bLastIniPkt;Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, · line 71
Quoted 8 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c +8
-0+ skb =dev_alloc_skb (frag_length +4 ); +if (skb) { +memcpy ((unsigned char *)(skb->cb), &dev,sizeof (dev)); + tcb_desc = (struct cb_desc *)(skb->cb +MAX_DEV_ADDR_SIZE ); + tcb_desc->queue_index =TXCMD_QUEUE ; + tcb_desc->bCmdOrInit =DESC_PACKET_TYPE_INIT ; + tcb_desc->bLastIniPkt = bLastIniPkt; + }and what happens here (below) if skb is NULL?
Nick,
I'm asking if you have completely fixed the bug or only partially fixed it. The answer is that the patch is only a partial fix. If skb is NULL, there is still a problem in the statement below here. The kernel will oops on that reference to skb, which is NULL.Quoted 18 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c +0
-1seg_ptr = skb->data;for (i =0 ; i < frag_length; i +=4 ) { *seg_ptr++ = ((i+0) < frag_length) ? --1.9.1
Quoted 7 lines
Quoted 3 lines
And I did check it against Linus's tree to make sure it applies , just to let you known.
Nick--
~RandySorry Randy.
I may be mis reading this, but are you asking me to write a different
commit message or is this patch just another bad patch in my series of bad patches?
Quoted 7 lines
Quoted 2 lines
--
~RandyRandy ,
Thanks for the catch :). Would you recommend just putting it in the if statement I created or create a second if statement for code readability.
Neither one of those choices. I suggest that the code immediately check for skb == NULL and return 0 (or false) if it is NULL. Then the code below that check won't need to be changed at all.
Signature · 1 line
~Randy
A message that is not in the archive (sent off-list or not yet received): CAPDOMVgChPhOfBdMAjQTJKmw5+LFO_7GoYU8A5ttDHMYHYY0fA@mail.gmail.com
Quoted 4 lines · Nick Krause
Thanks Randy for your help otherwise is my patch good? Please let me known if there our any other issues.
Regards Nick
I didn't notice any other issues with it.
Signature · 1 line
~Randy