mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: baihaowen <baihaowen@meizu.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Larry Finger <Larry.Finger@lwfinger.net>,
	Florian Schilhabel <florian.c.schilhabel@googlemail.com>,
	<linux-staging@lists.linux.dev>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] staging: rtl8712: Fix pointer dereferenced before checking
Date: Mon, 30 May 2022 16:44:23 +0800	[thread overview]
Message-ID: <6dd82c76-3064-3647-c08a-7d4e93d941d7@meizu.com> (raw)
In-Reply-To: <YpR/wHwWRbJ9cWbo@kroah.com>

在 2022/5/30 下午4:26, Greg Kroah-Hartman 写道:
> On Mon, May 30, 2022 at 04:22:11PM +0800, baihaowen wrote:
>> 在 2022/5/30 下午4:14, Greg Kroah-Hartman 写道:
>>> On Mon, May 30, 2022 at 04:05:32PM +0800, Haowen Bai wrote:
>>>> The padapter->recvpriv.signal_qual_data is dereferencing before null
>>>> checking, so move it after checking.
>>>>
>>>> Signed-off-by: Haowen Bai <baihaowen@meizu.com>
>>>> ---
>>>>  drivers/staging/rtl8712/rtl8712_recv.c | 4 +++-
>>>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c
>>>> index 7f1fdd058551..8ed94b259dbe 100644
>>>> --- a/drivers/staging/rtl8712/rtl8712_recv.c
>>>> +++ b/drivers/staging/rtl8712/rtl8712_recv.c
>>>> @@ -863,10 +863,12 @@ static void process_link_qual(struct _adapter *padapter,
>>>>  {
>>>>  	u32	last_evm = 0, tmpVal;
>>>>  	struct rx_pkt_attrib *pattrib;
>>>> -	struct smooth_rssi_data *sqd = &padapter->recvpriv.signal_qual_data;
>>>> +	struct smooth_rssi_data *sqd;
>>>>  
>>>>  	if (!prframe || !padapter)
>>>>  		return;
>>>> +
>>>> +	sqd = &padapter->recvpriv.signal_qual_data;
>>> How can padapter ever be NULL in this codepath?
>>>
>>> thanks,
>>>
>>> greg k-h
>> Just the original  code, show me
>>
>> if (!prframe || !padapter)
>>
>> It would be null, and then return.
> Again, trace things backwards, how can padapter ever be NULL?

padapter will not be null, since it's initialized by netdev_priv(pnetdev) and return if pnetdev is null. r871xu_drv_init() ...... pnetdev = r8712_init_netdev(); if (!pnetdev) goto error; padapter = netdev_priv(pnetdev); status = r8712_init_drv_sw(padapter); ......

-- 
Haowen Bai


  reply	other threads:[~2022-05-30  8:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-30  8:05 Haowen Bai
2022-05-30  8:14 ` Greg Kroah-Hartman
2022-05-30  8:22   ` baihaowen
2022-05-30  8:26     ` Greg Kroah-Hartman
2022-05-30  8:44       ` baihaowen [this message]
2022-05-30  9:29 ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6dd82c76-3064-3647-c08a-7d4e93d941d7@meizu.com \
    --to=baihaowen@meizu.com \
    --cc=Larry.Finger@lwfinger.net \
    --cc=florian.c.schilhabel@googlemail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®