From: Shreeya Patel <shreeya.patel23498@gmail.com>
To: "Tobin C. Harding" <me@tobin.cc>
Cc: gregkh@linuxfoundation.org, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Staging: rtlwifi: Remove NULL pointer dereference
Date: Wed, 11 Oct 2017 18:02:47 +0530 [thread overview]
Message-ID: <1507725167.2137.5.camel@gmail.com> (raw)
In-Reply-To: <20171010000607.GA29970@eros>
On Tue, 2017-10-10 at 11:06 +1100, Tobin C. Harding wrote:
> On Tue, Oct 10, 2017 at 02:48:58AM +0530, Shreeya Patel wrote:
> >
> > Remove NULL pointer dereference as it results in undefined
> > behaviour, and will usually lead to a runtime error.
> The diff does not show any pointer dereference so it is hard to
> understand what you are trying to do
> with this patch.
>
> >
> > Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
> > ---
> > drivers/staging/rtlwifi/base.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/staging/rtlwifi/base.c
> > b/drivers/staging/rtlwifi/base.c
> > index b88b0e8..5bb8f98 100644
> > --- a/drivers/staging/rtlwifi/base.c
> > +++ b/drivers/staging/rtlwifi/base.c
> > @@ -781,7 +781,7 @@ static void _rtl_txrate_selectmode(struct
> > ieee80211_hw *hw,
> >
> > struct rtl_priv *rtlpriv = rtl_priv(hw);
> > struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
> > - struct rtl_sta_info *sta_entry = NULL;
> > + struct rtl_sta_info *sta_entry;
> Now the pointer just has garbage in it instead of the testable value
> of NULL. If you are concerned
> with the dereference perhaps you could add a NULL check, again it's
> hard to say without seeing the
> code.
Hello,
Thanks for making me understand.
Here is the code after declaration and initialization of sta_entry.
Will it be good to add a NULL check in this case?
struct rtl_sta_info *sta_entry = NULL;
u8 ratr_index = SET_RATE_ID(RATR_INX_WIRELESS_MC);
if (sta) {
sta_entry = (struct rtl_sta_info *)sta->drv_priv;
ratr_index = sta_entry->ratr_index;
}
If we are making a pointer point to NULL then what if any other
variable is already pointing to NULL for some other purpose.
Instead, removing initialization will be good right?
>
> It is hard to see how this patch is correct though.
>
> Hope this helps,
> Tobin.
next prev parent reply other threads:[~2017-10-11 12:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-09 21:18 [PATCH] Staging: rtlwifi: Remove NULL pointer dereference Shreeya Patel
2017-10-10 0:06 ` Tobin C. Harding
2017-10-11 12:32 ` Shreeya Patel [this message]
2017-10-12 2:16 ` Tobin C. Harding
2017-10-13 18:55 ` Shreeya Patel
2017-10-11 19:11 ` kbuild test robot
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=1507725167.2137.5.camel@gmail.com \
--to=shreeya.patel23498@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=me@tobin.cc \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.