]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ALSA: caiaq: Handle probe errors properly
authorTakashi Iwai <tiwai@suse.de>
Tue, 14 Apr 2026 10:59:00 +0000 (12:59 +0200)
committerTakashi Iwai <tiwai@suse.de>
Wed, 15 Apr 2026 12:26:19 +0000 (14:26 +0200)
commit28abd224db4a49560b452115bca3672a20e45b2f
tree758436d305df438016dbdd2f99f9b5e73d75e72e
parente0da8a8cac74f4b9f577979d131f0d2b88a84487
ALSA: caiaq: Handle probe errors properly

The probe procedure of setup_card() in caiaq driver doesn't treat the
error cases gracefully, e.g. the error from snd_card_register() calls
snd_card_free() but continues.  This would lead to a UAF for the
further calls like snd_usb_caiaq_control_init(), as Berk suggested in
another patch in the link below.

However, the problem is not only that; in general, this function drops
the all error handlings (as it's a void function) although its caller
can propagate an error to snd_probe(), which eventually calls
snd_card_free() as a proper error path.  That said, we should treat
each error case in setup_card(), and just return the error code
promptly, which is then handled later as a fatal error in snd_probe().

This patch achieves it by changing the setup_card() to return an error
code.  Also, the superfluous snd_card_free() call is removed, too.

Note that card->private_free can be set still safely at returning an
error.  All called functions in card_free() have checks of the
unassigned resources or NULL checks.

Fixes: 8e3cd08ed8e5 ("[ALSA] caiaq - add control API and more input features")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/20260413034941.1131465-2-berkcgoksel@gmail.com
Link: https://patch.msgid.link/20260414105916.364073-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/caiaq/device.c