Linux wireless drivers development
 help / color / mirror / Atom feed
From: Bitterblue Smith <rtl8821cerfe2@gmail.com>
To: Ping-Ke Shih <pkshih@realtek.com>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Subject: Re: [PATCH rtw-next] wifi: rtw89: usb: Avoid crash with dynamically added device ID
Date: Mon, 17 Aug 2026 18:24:53 +0300	[thread overview]
Message-ID: <7fb431e3-2c7d-407f-916c-108d718ba891@gmail.com> (raw)
In-Reply-To: <84fa3f2903224073a3c5a9514d3f082a@realtek.com>

On 17/08/2026 06:38, Ping-Ke Shih wrote:
> Bitterblue Smith <rtl8821cerfe2@gmail.com> 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 <rtl8821cerfe2@gmail.com>
> 
> Acked-by: Ping-Ke Shih <pkshih@realtek.com>
> 
> 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.

      reply	other threads:[~2026-08-17 15:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-16 18:20 [PATCH rtw-next] wifi: rtw89: usb: Avoid crash with dynamically added device ID Bitterblue Smith
2026-08-17  3:38 ` Ping-Ke Shih
2026-08-17 15:24   ` Bitterblue Smith [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7fb431e3-2c7d-407f-916c-108d718ba891@gmail.com \
    --to=rtl8821cerfe2@gmail.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=pkshih@realtek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox