linux/sound/usb/caiaq
Nguyen Ngoc Thang 0b7bd20f63 ALSA: caiaq: unregister the input device when probe fails
setup_card() registers the input device, whose name and phys point into
struct snd_usb_caiaqdev, and then goes on to snd_card_register() and
snd_usb_caiaq_control_init(). If either fails, snd_probe() calls
snd_card_free(), which frees the device state but leaves the input
device registered: card_free() only clears the pointer, and the input
device is unregistered from snd_disconnect() alone. Reading its "uevent"
attribute afterwards dereferences freed memory:

  BUG: KASAN: slab-use-after-free in string+0x4a9/0x4f0
  Read of size 1 at addr ffff8880208f5043 by task caiaq/4967
   add_uevent_var+0x183/0x3a0
   input_dev_uevent+0x162/0x900
   dev_uevent+0x2f1/0x870
   uevent_show+0x1ca/0x3a0
   ...

Unregister the input device on the probe error path, as
snd_disconnect() does. snd_usb_caiaq_input_disconnect() is a no-op when
no input device was registered.

Reproduced with a raw-gadget Audio Kontrol 1 and a temporary hack that
makes snd_usb_caiaq_control_init() fail.

Fixes: 28abd224db ("ALSA: caiaq: Handle probe errors properly")
Cc: stable@vger.kernel.org
Reported-by: syzbot+2a123f6269da57ffefaa@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=2a123f6269da57ffefaa
Signed-off-by: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
Link: https://patch.msgid.link/20260925170717.22462-1-ngocthang2710.1999@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2026-09-28 13:43:26 +02:00
..
audio.c ALSA: caiaq: Fix potential double-free at error path 2026-09-03 18:08:24 +02:00
audio.h ALSA: caiaq: Use snd_card_free_when_closed() at disconnection 2024-11-13 13:33:47 +01:00
control.c ALSA: caiaq: Fix control_put() result and cache rollback 2026-04-17 17:52:00 +02:00
control.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
device.c ALSA: caiaq: unregister the input device when probe fails 2026-09-28 13:43:26 +02:00
device.h ALSA: caiaq: Decoupling ep1_in_urb in caiaq dev 2026-09-06 10:00:47 +02:00
input.c ALSA: usb-audio: caiaq: validate EP1 reply lengths 2026-07-05 12:14:19 +02:00
input.h ALSA: caiaq: Use snd_card_free_when_closed() at disconnection 2024-11-13 13:33:47 +01:00
Makefile treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
midi.c ALSA: caiaq: Decoupling ep1_in_urb in caiaq dev 2026-09-06 10:00:47 +02:00
midi.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00