linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] wifi: rtlwifi: fix USB device initialization sequence
@ 2023-10-27  7:59 Dmitry Antipov
  2023-10-27  8:22 ` Kalle Valo
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Antipov @ 2023-10-27  7:59 UTC (permalink / raw)
  To: Ping-Ke Shih; +Cc: Kalle Valo, linux-wireless, Dmitry Antipov

Do not ignore possible errors in '_rtl_usb_init()' and tweak error
handling in 'rtl_usb_probe()' to ensure that 'rtl_usb_cleanup()' is
called when needed. Minor style adjustments, compile tested only.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
 drivers/net/wireless/realtek/rtlwifi/usb.c | 25 ++++++++++++----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/usb.c b/drivers/net/wireless/realtek/rtlwifi/usb.c
index 30bf2775a335..12b8a5fae947 100644
--- a/drivers/net/wireless/realtek/rtlwifi/usb.c
+++ b/drivers/net/wireless/realtek/rtlwifi/usb.c
@@ -332,10 +332,11 @@ static int _rtl_usb_init(struct ieee80211_hw *hw)
 	}
 	/* usb endpoint mapping */
 	err = rtlpriv->cfg->usb_interface_cfg->usb_endpoint_mapping(hw);
-	rtlusb->usb_mq_to_hwq =  rtlpriv->cfg->usb_interface_cfg->usb_mq_to_hwq;
-	_rtl_usb_init_tx(hw);
-	_rtl_usb_init_rx(hw);
-	return err;
+	if (err)
+		return err;
+	rtlusb->usb_mq_to_hwq = rtlpriv->cfg->usb_interface_cfg->usb_mq_to_hwq;
+	err = _rtl_usb_init_tx(hw);
+	return err ? err : _rtl_usb_init_rx(hw);
 }
 
 static void rtl_usb_init_sw(struct ieee80211_hw *hw)
@@ -1033,37 +1034,39 @@ int rtl_usb_probe(struct usb_interface *intf,
 	/* Init IO handler */
 	_rtl_usb_io_handler_init(&udev->dev, hw);
 	rtlpriv->cfg->ops->read_chip_version(hw);
-	/*like read eeprom and so on */
+	/* like read eeprom and so on */
 	rtlpriv->cfg->ops->read_eeprom_info(hw);
 	err = _rtl_usb_init(hw);
 	if (err)
-		goto error_out2;
+		goto out_usb_init;
 	rtl_usb_init_sw(hw);
 	/* Init mac80211 sw */
 	err = rtl_init_core(hw);
 	if (err) {
 		pr_err("Can't allocate sw for mac80211\n");
-		goto error_out2;
+		goto out_core_init;
 	}
 	if (rtlpriv->cfg->ops->init_sw_vars(hw)) {
 		pr_err("Can't init_sw_vars\n");
-		goto error_out;
+		goto out;
 	}
 	rtl_init_sw_leds(hw);
 
 	err = ieee80211_register_hw(hw);
 	if (err) {
 		pr_err("Can't register mac80211 hw.\n");
-		goto error_out;
+		goto out;
 	}
 	rtlpriv->mac80211.mac80211_registered = 1;
 
 	set_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status);
 	return 0;
 
-error_out:
+out:
 	rtl_deinit_core(hw);
-error_out2:
+out_core_init:
+	rtl_usb_cleanup(hw);
+out_usb_init:
 	_rtl_usb_io_handler_release(hw);
 	usb_put_dev(udev);
 	complete(&rtlpriv->firmware_loading_complete);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] wifi: rtlwifi: fix USB device initialization sequence
  2023-10-27  7:59 [PATCH] wifi: rtlwifi: fix USB device initialization sequence Dmitry Antipov
@ 2023-10-27  8:22 ` Kalle Valo
  0 siblings, 0 replies; 2+ messages in thread
From: Kalle Valo @ 2023-10-27  8:22 UTC (permalink / raw)
  To: Dmitry Antipov; +Cc: Ping-Ke Shih, linux-wireless

Dmitry Antipov <dmantipov@yandex.ru> writes:

> Do not ignore possible errors in '_rtl_usb_init()' and tweak error
> handling in 'rtl_usb_probe()' to ensure that 'rtl_usb_cleanup()' is
> called when needed. Minor style adjustments, compile tested only.
>
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>

Patches like this should be tested on a real device, compile testing is
not enough. We don't know if there are hidden errors which this patch
then exposes.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-10-27  8:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-27  7:59 [PATCH] wifi: rtlwifi: fix USB device initialization sequence Dmitry Antipov
2023-10-27  8:22 ` Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).