linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Tuo Li <islituo@gmail.com>
Cc: gregkh@linuxfoundation.org, will+git@drnd.me,
	davidsondfgl@gmail.com, zhaoxiao@uniontech.com,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
	"baijiaju1990@gmail.com" <baijiaju1990@gmail.com>
Subject: Re: [BUG] staging: rtl8192e: possible null-pointer dereference in rtllib_wx_set_encode()
Date: Wed, 11 Aug 2021 10:33:11 +0300	[thread overview]
Message-ID: <20210811073311.GT22532@kadam> (raw)
In-Reply-To: <a86f508c-84b0-3523-2a8e-6710e35e5bb3@gmail.com>

On Wed, Aug 11, 2021 at 11:33:57AM +0800, Tuo Li wrote:
> Hello,
> 
> Our static analysis tool finds a possible null-pointer dereference in
> rtllib_wx.c in Linux 5.14.0-rc3:
> 
> The variable (*crypt)->ops is checked in:
> 342:    if (*crypt && (*crypt)->ops && strcmp((*crypt)->ops->name, "R-WEP")
> != 0)
> 
> This indicates that it can be NULL. If so, null-pointer dereferences will
> occur:
> 389:    (*crypt)->ops->set_key()
> 400:    len = (*crypt)->ops->get_key()
> 
> I am not quite sure whether this possible null-pointer dereference is real
> and how to fix it if it is real.
> Any feedback would be appreciated, thanks!
> 
> Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>

I don't *think* the check is required.

The data in ieee->crypt_info.crypt[idx] is set in rtllib_wx_set_encode()
and rtllib_wx_set_encode_ext() when we do "*crypt = new_crypt;".  (The
line is the same in both functions).  And in both cases ->ops is
non-NULL.

So probably the check should be removed.

On the other hand, I don't know the code very well and it's possible I
missed something.

regards,
dan carpenter

      reply	other threads:[~2021-08-11  7:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-11  3:33 [BUG] staging: rtl8192e: possible null-pointer dereference in rtllib_wx_set_encode() Tuo Li
2021-08-11  7:33 ` Dan Carpenter [this message]

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=20210811073311.GT22532@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=baijiaju1990@gmail.com \
    --cc=davidsondfgl@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=islituo@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=will+git@drnd.me \
    --cc=zhaoxiao@uniontech.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).