Skip to contentSkip to conversation

rtl8712: add a check for the status of register_netdev

PATCH Superseded Kangjie Lu 2 participants 3 messages Dec 26, 2018 Staging

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Kangjie Lu

author
#0 lore raw

PATCH 1/1 rtl8712: add a check for the status of register_netdev

register_netdev() may fail, so let's check its return value, and if it fails, issue an error message.

---
 drivers/staging/rtl8712/hal_init.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/rtl8712/hal_init.c +2 -1
index 7cdd609cab6c..7e2f8e0185d5 100644
@@ -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");
 }
 
 static const char firmware_file[] = "rtlwifi/rtl8712u.bin";
Signature · 1 line
2.17.2 (Apple Git-113)
#1 lore raw
Thank you for the patch! Yet something to improve:

Hi Kangjie,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on staging/staging-testing]
[also build test ERROR on v4.20 next-20181224]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Kangjie-Lu/rtl8712-add-a-check-for-the-status-of-register_netdev/20181226-094828
config: nds32-allmodconfig (attached as .config)
compiler: nds32le-linux-gcc (GCC) 6.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=6.4.0 make.cross ARCH=nds32

All errors (new ones prefixed by >>):

In file included from include/linux/usb/ch9.h:36:0,

                    from include/linux/usb.h:6,
                    from drivers/staging//rtl8712/hal_init.c:19:
   drivers/staging//rtl8712/hal_init.c: In function 'rtl871x_load_fw_cb':
>> drivers/staging//rtl8712/hal_init.c:49:12: error: 'udev' undeclared (first use in this function)
      dev_err(&udev->dev, "r8712u: Registering netdev failed\n");
               ^
   include/linux/device.h:1453:11: note: in definition of macro 'dev_err'
     _dev_err(dev, dev_fmt(fmt), ##__VA_ARGS__)
              ^~~
   drivers/staging//rtl8712/hal_init.c:49:12: note: each undeclared identifier is reported only once for each function it appears in
      dev_err(&udev->dev, "r8712u: Registering netdev failed\n");
               ^
   include/linux/device.h:1453:11: note: in definition of macro 'dev_err'
     _dev_err(dev, dev_fmt(fmt), ##__VA_ARGS__)
              ^~~

vim +/udev +49 drivers/staging//rtl8712/hal_init.c

    18	
  > 19	#include <linux/usb.h>
    20	#include <linux/device.h>
    21	#include <linux/usb/ch9.h>
    22	#include <linux/firmware.h>
    23	#include <linux/module.h>
    24	
    25	#include "osdep_service.h"
    26	#include "drv_types.h"
    27	#include "usb_osintf.h"
    28	
    29	#define FWBUFF_ALIGN_SZ 512
    30	#define MAX_DUMP_FWSZ	49152 /*default = 49152 (48k)*/
    31	
    32	static void rtl871x_load_fw_cb(const struct firmware *firmware, void *context)
    33	{
    34		struct _adapter *padapter = context;
    35	
    36		complete(&padapter->rtl8712_fw_ready);
    37		if (!firmware) {
    38			struct usb_device *udev = padapter->dvobjpriv.pusbdev;
    39			struct usb_interface *pusb_intf = padapter->pusb_intf;
    40	
    41			dev_err(&udev->dev, "r8712u: Firmware request failed\n");
    42			usb_put_dev(udev);
    43			usb_set_intfdata(pusb_intf, NULL);
    44			return;
    45		}
    46		padapter->fw = firmware;
    47		/* firmware available - start netdev */
    48		if (register_netdev(padapter->pnetdev))
  > 49			dev_err(&udev->dev, "r8712u: Registering netdev failed\n");
    50	}
    51	

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#2 lore raw
In reply to Kangjie Lu
Thank you for the patch! Yet something to improve:

Hi Kangjie,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on staging/staging-testing]
[also build test ERROR on v4.20 next-20181224]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Kangjie-Lu/rtl8712-add-a-check-for-the-status-of-register_netdev/20181226-094828
config: xtensa-allmodconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 8.1.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=8.1.0 make.cross ARCH=xtensa

All errors (new ones prefixed by >>):

In file included from include/linux/usb/ch9.h:36,

                    from include/linux/usb.h:6,
                    from drivers/staging/rtl8712/hal_init.c:19:
   drivers/staging/rtl8712/hal_init.c: In function 'rtl871x_load_fw_cb':
>> drivers/staging/rtl8712/hal_init.c:49:12: error: 'udev' undeclared (first use in this function); did you mean 'cdev'?
      dev_err(&udev->dev, "r8712u: Registering netdev failed\n");
               ^~~~
   include/linux/device.h:1453:11: note: in definition of macro 'dev_err'
     _dev_err(dev, dev_fmt(fmt), ##__VA_ARGS__)
              ^~~
   drivers/staging/rtl8712/hal_init.c:49:12: note: each undeclared identifier is reported only once for each function it appears in
      dev_err(&udev->dev, "r8712u: Registering netdev failed\n");
               ^~~~
   include/linux/device.h:1453:11: note: in definition of macro 'dev_err'
     _dev_err(dev, dev_fmt(fmt), ##__VA_ARGS__)
              ^~~

vim +49 drivers/staging/rtl8712/hal_init.c

    18	
  > 19	#include <linux/usb.h>
    20	#include <linux/device.h>
    21	#include <linux/usb/ch9.h>
    22	#include <linux/firmware.h>
    23	#include <linux/module.h>
    24	
    25	#include "osdep_service.h"
    26	#include "drv_types.h"
    27	#include "usb_osintf.h"
    28	
    29	#define FWBUFF_ALIGN_SZ 512
    30	#define MAX_DUMP_FWSZ	49152 /*default = 49152 (48k)*/
    31	
    32	static void rtl871x_load_fw_cb(const struct firmware *firmware, void *context)
    33	{
    34		struct _adapter *padapter = context;
    35	
    36		complete(&padapter->rtl8712_fw_ready);
    37		if (!firmware) {
    38			struct usb_device *udev = padapter->dvobjpriv.pusbdev;
    39			struct usb_interface *pusb_intf = padapter->pusb_intf;
    40	
    41			dev_err(&udev->dev, "r8712u: Firmware request failed\n");
    42			usb_put_dev(udev);
    43			usb_set_intfdata(pusb_intf, NULL);
    44			return;
    45		}
    46		padapter->fw = firmware;
    47		/* firmware available - start netdev */
    48		if (register_netdev(padapter->pnetdev))
  > 49			dev_err(&udev->dev, "r8712u: Registering netdev failed\n");
    50	}
    51	

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation