rtw89 USB: crash fix and RTL8922AU IDs for 7.3.y
Hi,
please consider these upstream commits for 7.3.y:
b1827227176821af9bba0cb643728d23328f3660 wifi: rtw89: usb: Avoid crash with dynamically added device ID de2cb461456143a69845c24ce38ac14a61d6e166 wifi: rtw89: 8922au: Add support for TP-Link TBE400U 475539db19530b7e134f58555e1afcae21d419f3 wifi: rtw89: 8922au: add ASUS BE93
The first one fixes a NULL pointer dereference when a device ID is added through new_id, the other two only add device IDs. They apply cleanly to 7.3.5 and build without warnings. I did not reproduce the crash myself.
I will send a backport of the first one for 6.18.y, where the RTL8922AU driver does not exist.
Thanks,
Josef
PATCH 1/1 wifi: rtw89: usb: Avoid crash with dynamically added device ID
From: Bitterblue Smith <[email protected]>
[ Upstream commit b1827227176821af9bba0cb643728d23328f3660 ]
Adding a device ID via sysfs causes a crash when the device is plugged in, because the driver_info pointer is null.
Check for null driver_info in rtw89_usb_probe() and add a wrapper in each driver to pass it a reasonable default value.
[ Dropped the hunks for rtw8852au.c, rtw8852cu.c and rtw8922au.c,
these drivers are not in 6.18. ]
---
Compile tested on 6.18.64 (arm64 defconfig with the rtw89 USB drivers, W=1, no warnings). The probe through an ID added with new_id was exercised with the upstream version of this fix in backports 7.2 on an RTL8922AU. The commit is requested for 7.3.y as well.
drivers/net/wireless/realtek/rtw89/rtw8851bu.c | 8 +++++++- drivers/net/wireless/realtek/rtw89/rtw8852bu.c | 8 +++++++- drivers/net/wireless/realtek/rtw89/usb.c | 5 ++++- drivers/net/wireless/realtek/rtw89/usb.h | 3 ++- 4 files changed, 20 insertions(+), 4 deletions(-)
drivers/net/wireless/realtek/rtw89/rtw8851bu.c +7 -1
@@ -32,10 +32,16 @@ static const struct usb_device_id rtw_8851bu_id_table[] = { };MODULE_DEVICE_TABLE (usb, rtw_8851bu_id_table); +static int rtw8851bu_probe (struct usb_interface *intf, +const struct usb_device_id *id) +{ +return rtw89_usb_probe (intf, id, &rtw89_8851bu_info); +} +static struct usb_driver rtw_8851bu_driver = { .name =KBUILD_MODNAME , .id_table = rtw_8851bu_id_table, - .probe = rtw89_usb_probe, + .probe = rtw8851bu_probe, .disconnect = rtw89_usb_disconnect, };module_usb_driver (rtw_8851bu_driver);
drivers/net/wireless/realtek/rtw89/rtw8852bu.c +7 -1
@@ -46,10 +46,16 @@ static const struct usb_device_id rtw_8852bu_id_table[] = { };MODULE_DEVICE_TABLE (usb, rtw_8852bu_id_table); +static int rtw8852bu_probe (struct usb_interface *intf, +const struct usb_device_id *id) +{ +return rtw89_usb_probe (intf, id, &rtw89_8852bu_info); +} +static struct usb_driver rtw_8852bu_driver = { .name =KBUILD_MODNAME , .id_table = rtw_8852bu_id_table, - .probe = rtw89_usb_probe, + .probe = rtw8852bu_probe, .disconnect = rtw89_usb_disconnect, };module_usb_driver (rtw_8852bu_driver);
drivers/net/wireless/realtek/rtw89/usb.c +4 -1
@@ -931,7 +931,8 @@ static void rtw89_usb_intf_deinit(struct rtw89_dev *rtwdev, }int rtw89_usb_probe (struct usb_interface *intf, -const struct usb_device_id *id) +const struct usb_device_id *id, +const struct rtw89_driver_info *default_info) {const struct rtw89_driver_info *info;struct rtw89_dev *rtwdev;
@@ -939,6 +940,8 @@ int rtw89_usb_probe(struct usb_interface *intf,int ret; info = (const struct rtw89_driver_info *)id->driver_info; +if (!info) + info = default_info; rtwdev = rtw89_alloc_ieee80211_hw(&intf->dev, sizeof(struct rtw89_usb),
drivers/net/wireless/realtek/rtw89/usb.h +2 -1
@@ -59,7 +59,8 @@ static inline struct rtw89_usb *rtw89_usb_priv(struct rtw89_dev *rtwdev) }int rtw89_usb_probe (struct usb_interface *intf, -const struct usb_device_id *id); +const struct usb_device_id *id, +const struct rtw89_driver_info *default_info);void rtw89_usb_disconnect (struct usb_interface *intf);#endif
Signature · 1 line
2.54.0 (Apple Git-157)
Sasha Levin
maintainerQuoted 5 lines
please consider these upstream commits for 7.3.y:
b1827227176821af9bba0cb643728d23328f3660wifi: rtw89: usb: Avoid crash with dynamically added device IDde2cb461456143a69845c24ce38ac14a61d6e166wifi: rtw89: 8922au: Add support for TP-Link TBE400U475539db19530b7e134f58555e1afcae21d419f3wifi: rtw89: 8922au: add ASUS BE93
[...]
Quoted 2 lines
I will send a backport of the first one for 6.18.y, where the RTL8922AU driver does not exist.
Queued all three for 7.3, and your backport of the first one for 6.18, thanks.
Signature · 2 lines
Thanks, Sasha