Skip to content

Commit

Permalink
wifi: rtw88: usb: kill and free rx urbs on probe failure
Browse files Browse the repository at this point in the history
commit 2905643 upstream.

After rtw_usb_alloc_rx_bufs() has been called rx urbs have been
allocated and must be freed in the error path. After rtw_usb_init_rx()
has been called they are submitted, so they also must be killed.

Add these forgotten steps to the probe error path.

Besides the lost memory this also fixes a problem when the driver
fails to download the firmware in rtw_chip_info_setup(). In this
case it can happen that the completion of the rx urbs handler runs
at a time when we already freed our data structures resulting in
a kernel crash.

Fixes: a82dfd3 ("wifi: rtw88: Add common USB chip support")
Cc: stable@vger.kernel.org
Reported-by: Ilgaz Öcal <ilgaz@ilgaz.gen.tr>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230823075021.588596-1-s.hauer@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
saschahauer authored and gregkh committed Sep 6, 2023
1 parent bf5d3fa commit c42a827
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/net/wireless/realtek/rtw88/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ int rtw_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)

ret = rtw_core_init(rtwdev);
if (ret)
goto err_release_hw;
goto err_free_rx_bufs;

ret = rtw_usb_intf_init(rtwdev, intf);
if (ret) {
Expand Down Expand Up @@ -890,6 +890,9 @@ int rtw_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
err_deinit_core:
rtw_core_deinit(rtwdev);

err_free_rx_bufs:
rtw_usb_free_rx_bufs(rtwusb);

err_release_hw:
ieee80211_free_hw(hw);

Expand Down

0 comments on commit c42a827

Please sign in to comment.