Re: [PATCH] Staging: rtlwifi: Remove NULL pointer dereference

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
> > ---
> >  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.
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux