RE: [PATCH rtw-next] wifi: rtw89: usb: Avoid crash with dynamically added device ID
Ping-Ke Shih <[email protected]>
| Newsgroups | org.kernel.vger.linux-wireless |
|---|---|
| Message-ID | <[email protected]> |
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 > > 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; }