Re: [PATCH v2] rtl8712: add a check for the status of register_netdev

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

 



On Tue, Dec 25, 2018 at 08:39:53PM -0600, Kangjie Lu wrote:
> register_netdev() may fail, so let's check its return value, and if it
> fails, issue an error message.
> 
> Signed-off-by: Kangjie Lu <kjlu@xxxxxxx>
> ---
>  drivers/staging/rtl8712/hal_init.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c
> index 7cdd609cab6c..ca0858660a45 100644
> --- a/drivers/staging/rtl8712/hal_init.c
> +++ b/drivers/staging/rtl8712/hal_init.c
> @@ -32,10 +32,10 @@
>  static void rtl871x_load_fw_cb(const struct firmware *firmware, void *context)
>  {
>  	struct _adapter *padapter = context;
> +	struct usb_device *udev = padapter->dvobjpriv.pusbdev;
>  
>  	complete(&padapter->rtl8712_fw_ready);
>  	if (!firmware) {
> -		struct usb_device *udev = padapter->dvobjpriv.pusbdev;
>  		struct usb_interface *pusb_intf = padapter->pusb_intf;
>  
>  		dev_err(&udev->dev, "r8712u: Firmware request failed\n");
> @@ -45,7 +45,8 @@ static void rtl871x_load_fw_cb(const struct firmware *firmware, void *context)
>  	}
>  	padapter->fw = firmware;
>  	/* firmware available - start netdev */
> -	register_netdev(padapter->pnetdev);
> +	if (register_netdev(padapter->pnetdev))
> +		dev_err(&udev->dev, "r8712u: Registering netdev failed\n");

This error handling doesn't seem complete.  You're just adding the
minimum to make the static analysis tool happy.

If you leave the code as-is, maybe someone else will see the static
analysis warning and fix it properly.  But you're silencing the warning
so now no one will fix it.

Warnings are valuable.  Don't silence them without fixing the bug.

regards,
dan carpenter

_______________________________________________
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