Skip to contentSkip to conversation

staging: rtl8712: add error handling for register_netdev

PATCH In review Zhouyang Jia 2 participants 2 messages Jun 12, 2018 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: rtl8712: add error handling for register_netdev

When register_netdev fails, the lack of error-handling code may cause unexpected results.

This patch adds error-handling code after calling register_netdev.

---
 drivers/staging/rtl8712/hal_init.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/staging/rtl8712/hal_init.c +7 -1
index 2a3f074..2b47e75 100644
@@ -40,6 +40,7 @@
 static void rtl871x_load_fw_cb(const struct firmware *firmware, void *context)
 {
 	struct _adapter *padapter = context;
+	int rc;
 
 	complete(&padapter->rtl8712_fw_ready);
 	if (!firmware) {
@@ -53,7 +54,12 @@ static void rtl871x_load_fw_cb(const struct firmware *firmware, void *context)
 	}
 	padapter->fw = firmware;
 	/* firmware available - start netdev */
-	register_netdev(padapter->pnetdev);
+	rc = register_netdev(padapter->pnetdev);
+	if (rc) {
+		struct usb_device *udev = padapter->dvobjpriv.pusbdev;
+
+		dev_err(&udev->dev, "r8712u: Unable to register netdev\n");
+	}
 }
 
 static const char firmware_file[] = "rtlwifi/rtl8712u.bin";
Signature · 1 line
2.7.4
#1 lore raw
Quoted 5 lines · Zhouyang Jia

When register_netdev fails, the lack of error-handling code may cause unexpected results.

This patch adds error-handling code after calling register_netdev.

It doesn't add any error handling. It just adds an error message.

The error handling does look sort of messed up, but this isn't a useful patch.

regards,
dan carpenter