Jiaming Zhang
unread,Oct 14, 2025, 12:02:00 AM (6 days ago) Oct 14Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to gre...@linuxfoundation.org, bro...@kernel.org, cryo...@uniontech.com, linux-...@vger.kernel.org, linux...@vger.kernel.org, pe...@perex.cz, pierre-lou...@linux.dev, quic_...@quicinc.com, r7725...@gmail.com, syzk...@googlegroups.com, ti...@suse.com
Hi Greg,
Thanks for the guidance. You're right, the root cause of this issue is
that a USB audio device is created without a proper interface.
To fix this issue, I added a check for the NULL return value in
try_to_register_card() before calling usb_interface_claimed().
I have tested patch with the reproducer on the latest version (v6.18-rc1),
the issue was not triggered again.
Please let me know if any changes are needed.
Best regards,
Jiaming Zhang
---
In try_to_register_card(), the return value of usb_ifnum_to_if() is
passed directly to usb_interface_claimed() without a NULL check, which
will lead to a NULL pointer dereference when creating an invalid
USB audio device. Fix this by adding a check to ensure the interface
pointer is valid before passing it to usb_interface_claimed().
Reported-by: Jiaming Zhang <
r7725...@gmail.com>
Signed-off-by: Jiaming Zhang <
r7725...@gmail.com>
---
sound/usb/card.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 1d5a65eac933..270dad84d825 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -891,10 +891,16 @@ get_alias_quirk(struct usb_device *dev, unsigned int id)
*/
static int try_to_register_card(struct snd_usb_audio *chip, int ifnum)
{
+ struct usb_interface *iface;
+
if (check_delayed_register_option(chip) == ifnum ||
- chip->last_iface == ifnum ||
- usb_interface_claimed(usb_ifnum_to_if(chip->dev, chip->last_iface)))
+ chip->last_iface == ifnum)
+ return snd_card_register(chip->card);
+
+ iface = usb_ifnum_to_if(chip->dev, chip->last_iface);
+ if (iface && usb_interface_claimed(iface))
return snd_card_register(chip->card);
+
return 0;
}
--
2.34.1