Re: [PATCH] staging: r8188eu: remove unnecessary NULL check

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

 



On Tue, Nov 23, 2021 at 01:23:50AM +0530, Vihas Mak wrote:
> remove unnecessary NULL check surrounding rtw_free_netdev(), as the check
> is already performed inside rtw_free_netdev() in
> drivers/staging/r8188eu/os_dep/osdep_service.c.
> 
> Signed-off-by: Vihas Mak <makvihas@xxxxxxxxx>
> ---
>  drivers/staging/r8188eu/os_dep/usb_intf.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c
> index 5a35d9fe3fc9..392bd7868519 100644
> --- a/drivers/staging/r8188eu/os_dep/usb_intf.c
> +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c
> @@ -466,8 +466,7 @@ static void rtw_usb_if1_deinit(struct adapter *if1)
>  		if1->hw_init_completed);
>  	rtw_handle_dualmac(if1, 0);
>  	rtw_free_drv_sw(if1);
> -	if (pnetdev)
> -		rtw_free_netdev(pnetdev);
> +	rtw_free_netdev(pnetdev);
>  }

I'm not a huge fan of these sorts of patches.  They don't make the code
more readable because they hide the complexity.

Occasionally we will get a forest cobra in our yard and everyone is
screaming and panicking.  I'm like, "Calm down.  Once you've spotted the
snake, even a deadly snake, then the danger has passed."  You can just
stay two or three meters away and you're fine.  Call a snake catcher.

What you're doing here is you've got a potential NULL dereference which
is the snake.  And this patch is saying, "Snakes are so messy!  Let's
hide it in the bushes next to the sidewalk where no one can see it."

Hash tag, folksy wisdom.  #snakes

On the other hand, it might be worth checking if "pnetdev" can even be
NULL at this point, and then deleting both of the NULL checks.  That
would be a very good clean up.

regards,
dan carpenter




[Index of Archives]     [Linux Driver Development]     [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