Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH] ALSA: usb-audio: Abort properly at errors for Extidy boot quirk
@ 2026-11-03 15:31 Takashi Iwai
  2026-11-03 15:41 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Takashi Iwai @ 2026-11-03 15:31 UTC (permalink / raw)
  To: linux-sound

The boot quirk for Extigy tries to continue even if the extraction of
a new device descriptor fails, and it means an uninitialized data is
copied onto the device.

Abort properly upon errors for safety, instead.
Also, make the error messages more visible, as they are now supposed to
be real errors.

Fixes: b909df18ce2a ("ALSA: usb-audio: Fix potential out-of-bound accesses for Extigy and Mbox devices")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/usb/quirks.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index 05a9f6727a3a..220ac9b10238 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -575,13 +575,18 @@ static int snd_usb_extigy_boot_quirk(struct usb_device *dev, struct usb_interfac
 			return -ENOMEM;
 		err = usb_get_descriptor(dev, USB_DT_DEVICE, 0,
 				new_device_descriptor, sizeof(*new_device_descriptor));
-		if (err < 0)
-			dev_dbg(&dev->dev, "error usb_get_descriptor: %d\n", err);
-		if (new_device_descriptor->bNumConfigurations > dev->descriptor.bNumConfigurations)
-			dev_dbg(&dev->dev, "error too large bNumConfigurations: %d\n",
+		if (err < 0) {
+			dev_err(&dev->dev, "error usb_get_descriptor: %d\n", err);
+			return -ENODEV;
+		}
+
+		if (new_device_descriptor->bNumConfigurations > dev->descriptor.bNumConfigurations) {
+			dev_err(&dev->dev, "error too large bNumConfigurations: %d\n",
 				new_device_descriptor->bNumConfigurations);
-		else
-			memcpy(&dev->descriptor, new_device_descriptor, sizeof(dev->descriptor));
+			return -ENODEV;
+		}
+
+		memcpy(&dev->descriptor, new_device_descriptor, sizeof(dev->descriptor));
 		err = usb_reset_configuration(dev);
 		if (err < 0)
 			dev_dbg(&dev->dev, "error usb_reset_configuration: %d\n", err);
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-03 15:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-03 15:31 [PATCH] ALSA: usb-audio: Abort properly at errors for Extidy boot quirk Takashi Iwai
2026-11-03 15:41 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox