From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752637AbaHKSpN (ORCPT ); Mon, 11 Aug 2014 14:45:13 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:50408 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751109AbaHKSpL (ORCPT ); Mon, 11 Aug 2014 14:45:11 -0400 Message-ID: <53E90F34.9030809@infradead.org> Date: Mon, 11 Aug 2014 11:45:08 -0700 From: Randy Dunlap User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Nick Krause CC: Greg KH , "devel@driverdev.osuosl.org" , lisa@xenapiadmin.com, Ben Hutchings , Valentina Manea , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] staging: Check against NULL in fw_download_code References: <1407780151-4674-1-git-send-email-xerofoify@gmail.com> <53E9066A.3030801@infradead.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: 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 wrote: >> On 08/11/14 11:04, Nick Krause wrote: >>> On Mon, Aug 11, 2014 at 2:02 PM, Nicholas Krause 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 >>>> --- >>>> 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