Re: [PATCH rtw-next] wifi: rtw89: usb: Avoid crash with dynamically added device ID
Bitterblue Smith <[email protected]>
| Newsgroups | org.kernel.vger.linux-wireless |
|---|---|
| Message-ID | <[email protected]> |
On 17/08/2026 06:38, Ping-Ke Shih wrote: > Bitterblue Smith <[email protected]> wrote: >> Adding a device ID via sysfs causes a crash when the device is plugged >> in, because the driver_info pointer is null. > > I don't know about this before. Does it looks like? > > echo "1234 5678" | sudo tee /sys/bus/usb/drivers/my_driver/new_id > Yes, like that. A few people have tried to use it recently to test new devices and got crashes. >> >> Add a wrapper around rtw89_usb_probe() in each driver to check if >> driver_info is null and provide a reasonable default value for it. >> >> Signed-off-by: Bitterblue Smith <[email protected]> > > Acked-by: Ping-Ke Shih <[email protected]> > > I'd give my acked-by in advance. But you still can consider my opinion below. > >> --- >> The PCI side has the same problem, but new device IDs are a lot less >> likely there. > > Thanks for the info. > > [...] > >> +static int rtw8851bu_probe(struct usb_interface *intf, >> + const struct usb_device_id *id) >> +{ >> + const struct rtw89_driver_info *info; >> + >> + if (id->driver_info) >> + info = (const struct rtw89_driver_info *)id->driver_info; >> + else >> + info = &rtw89_8851bu_info; >> + >> + return rtw89_usb_probe(intf, info); >> +} >> + > > If you want to simply specific probe(), here might be > > static int rtw8851bu_probe(struct usb_interface *intf, > const struct usb_device_id *id) > { > return rtw89_usb_probe(intf, id, &rtw89_8851bu_info); > } > > Then > > int rtw89_usb_probe(struct usb_interface *intf, > const struct usb_device_id *id, > const struct rtw89_driver_info *default_info) > { > ... > > info = (const struct rtw89_driver_info *)id->driver_info; > if (!info) > info = default_info; > } > > Ah, yes, that is better.