* Re: [PATCH] staging: Check against NULL in fw_download_code [not found] ` <CAPDOMVghgyQ72J6MS6uaWEeMFBvzDNmfoAS5Tbd7+XO_KgUmHg@mail.gmail.com> @ 2014-08-11 18:07 ` Randy Dunlap [not found] ` <CAPDOMViHWMRRMqdEpjft0TDuVSLai8LuWRcXPdMeCtUYgB2sgw@mail.gmail.com> 0 siblings, 1 reply; 4+ messages in thread From: Randy Dunlap @ 2014-08-11 18:07 UTC (permalink / raw) To: Nick Krause, Greg KH Cc: devel@driverdev.osuosl.org, lisa, Ben Hutchings, Valentina Manea, linux-kernel@vger.kernel.org On 08/11/14 11:04, Nick Krause wrote: > On Mon, Aug 11, 2014 at 2:02 PM, Nicholas Krause <xerofoify@gmail.com> wrote: >> 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 in fw_download_code >> and after checking I fixed it to check for the NULL value before using the allocate >> skb. >> >> Signed-off-by: Nicholas Krause <xerofoify@gmail.com> >> --- >> drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c | 14 ++++++++------ >> 1 file changed, 8 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c >> index 1a95d1f..0a4c926 100644 >> --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c >> +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c >> @@ -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; >> >> + 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? >> seg_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 -- ~Randy ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <CAPDOMViHWMRRMqdEpjft0TDuVSLai8LuWRcXPdMeCtUYgB2sgw@mail.gmail.com>]
* Re: [PATCH] staging: Check against NULL in fw_download_code [not found] ` <CAPDOMViHWMRRMqdEpjft0TDuVSLai8LuWRcXPdMeCtUYgB2sgw@mail.gmail.com> @ 2014-08-11 18:45 ` Randy Dunlap [not found] ` <CAPDOMVj0YcDc5ATxMiTLeciadJPiQxV2ap8Wo3Qg4RM=yeXmVQ@mail.gmail.com> 0 siblings, 1 reply; 4+ messages in thread From: Randy Dunlap @ 2014-08-11 18:45 UTC (permalink / raw) To: Nick Krause Cc: Greg KH, devel@driverdev.osuosl.org, lisa, Ben Hutchings, Valentina Manea, linux-kernel@vger.kernel.org On 08/11/14 11:26, Nick Krause wrote: > On Mon, Aug 11, 2014 at 2:07 PM, Randy Dunlap <rdunlap@infradead.org> wrote: >> On 08/11/14 11:04, Nick Krause wrote: >>> On Mon, Aug 11, 2014 at 2:02 PM, Nicholas Krause <xerofoify@gmail.com> wrote: >>>> 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 in fw_download_code >>>> and after checking I fixed it to check for the NULL value before using the allocate >>>> skb. >>>> >>>> Signed-off-by: Nicholas Krause <xerofoify@gmail.com> >>>> --- >>>> drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c | 14 ++++++++------ >>>> 1 file changed, 8 insertions(+), 6 deletions(-) >>>> >>>> diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c >>>> index 1a95d1f..0a4c926 100644 >>>> --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c >>>> +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c >>>> @@ -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; >>>> >>>> + 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. >> >>>> seg_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 >> >> >> -- >> ~Randy > Sorry 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? -- ~Randy ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <CAPDOMVj0YcDc5ATxMiTLeciadJPiQxV2ap8Wo3Qg4RM=yeXmVQ@mail.gmail.com>]
* Re: [PATCH] staging: Check against NULL in fw_download_code [not found] ` <CAPDOMVj0YcDc5ATxMiTLeciadJPiQxV2ap8Wo3Qg4RM=yeXmVQ@mail.gmail.com> @ 2014-08-11 19:04 ` Randy Dunlap [not found] ` <CAPDOMVgChPhOfBdMAjQTJKmw5+LFO_7GoYU8A5ttDHMYHYY0fA@mail.gmail.com> 0 siblings, 1 reply; 4+ messages in thread From: Randy Dunlap @ 2014-08-11 19:04 UTC (permalink / raw) To: Nick Krause Cc: Greg KH, devel@driverdev.osuosl.org, lisa, Ben Hutchings, Valentina Manea, linux-kernel@vger.kernel.org On 08/11/14 11:55, Nick Krause wrote: > On Mon, Aug 11, 2014 at 2:45 PM, Randy Dunlap <rdunlap@infradead.org> wrote: >> On 08/11/14 11:26, Nick Krause wrote: >>> On Mon, Aug 11, 2014 at 2:07 PM, Randy Dunlap <rdunlap@infradead.org> wrote: >>>> On 08/11/14 11:04, Nick Krause wrote: >>>>> On Mon, Aug 11, 2014 at 2:02 PM, Nicholas Krause <xerofoify@gmail.com> wrote: >>>>>> 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 in fw_download_code >>>>>> and after checking I fixed it to check for the NULL value before using the allocate >>>>>> skb. >>>>>> >>>>>> Signed-off-by: Nicholas Krause <xerofoify@gmail.com> >>>>>> --- >>>>>> drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c | 14 ++++++++------ >>>>>> 1 file changed, 8 insertions(+), 6 deletions(-) >>>>>> >>>>>> diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c >>>>>> index 1a95d1f..0a4c926 100644 >>>>>> --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c >>>>>> +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c >>>>>> @@ -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; >>>>>> >>>>>> + 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. >> >>>> >>>>>> seg_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 >>>> >>>> >>>> -- >>>> ~Randy >>> Sorry 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? >> >> >> -- >> ~Randy > > Randy , > 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. -- ~Randy ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <CAPDOMVgChPhOfBdMAjQTJKmw5+LFO_7GoYU8A5ttDHMYHYY0fA@mail.gmail.com>]
* Re: [PATCH] staging: Check against NULL in fw_download_code [not found] ` <CAPDOMVgChPhOfBdMAjQTJKmw5+LFO_7GoYU8A5ttDHMYHYY0fA@mail.gmail.com> @ 2014-08-11 19:40 ` Randy Dunlap 0 siblings, 0 replies; 4+ messages in thread From: Randy Dunlap @ 2014-08-11 19:40 UTC (permalink / raw) To: Nick Krause Cc: Greg KH, devel@driverdev.osuosl.org, lisa, Ben Hutchings, Valentina Manea, linux-kernel@vger.kernel.org On 08/11/14 12:18, Nick Krause wrote: > > 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. -- ~Randy ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-08-11 19:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1407780151-4674-1-git-send-email-xerofoify@gmail.com>
[not found] ` <CAPDOMVghgyQ72J6MS6uaWEeMFBvzDNmfoAS5Tbd7+XO_KgUmHg@mail.gmail.com>
2014-08-11 18:07 ` [PATCH] staging: Check against NULL in fw_download_code Randy Dunlap
[not found] ` <CAPDOMViHWMRRMqdEpjft0TDuVSLai8LuWRcXPdMeCtUYgB2sgw@mail.gmail.com>
2014-08-11 18:45 ` Randy Dunlap
[not found] ` <CAPDOMVj0YcDc5ATxMiTLeciadJPiQxV2ap8Wo3Qg4RM=yeXmVQ@mail.gmail.com>
2014-08-11 19:04 ` Randy Dunlap
[not found] ` <CAPDOMVgChPhOfBdMAjQTJKmw5+LFO_7GoYU8A5ttDHMYHYY0fA@mail.gmail.com>
2014-08-11 19:40 ` Randy Dunlap
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox