From: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
To: Larry Finger <Larry.Finger@lwfinger.net>,
Phillip Potter <phil@philpotter.co.uk>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Michael Straube <straube.linux@gmail.com>,
Vihas Makwana <makvihas@gmail.com>
Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
Dan Carpenter <dan.carpenter@oracle.com>,
Pavel Skripkin <paskripkin@gmail.com>,
Vihas Makwana <makvihas@gmail.com>
Subject: Re: [PATCH] staging: r8188eu: fix a potential NULL pointer dereference
Date: Sun, 24 Apr 2022 01:47:35 +0200 [thread overview]
Message-ID: <3607997.MHq7AAxBmi@leap> (raw)
In-Reply-To: <20220423184745.21134-1-makvihas@gmail.com>
On sabato 23 aprile 2022 20:47:48 CEST Vihas Makwana wrote:
> recvframe_chk_defrag() performs a NULL check on psta, but if that check
> fails then it dereferences it, which it shouldn't do as psta is NULL.
>
> Set pdefrag_q to NULL if above check fails and let the code after it
handle
> that case.
>
> Fixes: 1cc18a22b96b ("staging: r8188eu: Add files for new driver - part
5")
> Signed-off-by: Vihas Makwana <makvihas@gmail.com>
> ---
> drivers/staging/r8188eu/core/rtw_recv.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/
r8188eu/core/rtw_recv.c
> index c1005ddaa..db54bceff 100644
> --- a/drivers/staging/r8188eu/core/rtw_recv.c
> +++ b/drivers/staging/r8188eu/core/rtw_recv.c
> @@ -1244,7 +1244,7 @@ struct recv_frame *recvframe_chk_defrag(struct
adapter *padapter, struct recv_fr
> pdefrag_q = NULL;
> }
> } else {
> - pdefrag_q = &psta->sta_recvpriv.defrag_q;
> + pdefrag_q = NULL;
Hi Vihas,
To me the code looks like this...
struct sta_info *psta;
...
psta = rtw_get_stainfo(pstapriv, psta_addr);
/* The code is about to test if "psta" is a valid pointer */
if (!psta) {
/* "psta" is NULL */
...
} else {
/* "psta" is not NULL */
...
> }
>
Also, even if "psta" were NULL (but it isn't), your change would still be
no good.
Please be very careful with these types of changes next time :)
Thanks,
Fabio M. De Francesco
> if ((ismfrag == 0) && (fragnum == 0))
> --
> 2.30.2
>
next prev parent reply other threads:[~2022-04-23 23:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-23 18:47 [PATCH] staging: r8188eu: fix a potential NULL pointer dereference Vihas Makwana
2022-04-23 23:47 ` Fabio M. De Francesco [this message]
2022-04-24 9:27 ` Vihas Makwana
2022-04-24 9:47 ` Vihas Makwana
2022-04-25 8:22 ` 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=3607997.MHq7AAxBmi@leap \
--to=fmdefrancesco@gmail.com \
--cc=Larry.Finger@lwfinger.net \
--cc=dan.carpenter@oracle.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=makvihas@gmail.com \
--cc=paskripkin@gmail.com \
--cc=phil@philpotter.co.uk \
--cc=straube.linux@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).