]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ALSA: usb-audio: Fix potential leak of pd at parsing UAC3 streams
authorTakashi Iwai <tiwai@suse.de>
Mon, 27 Apr 2026 15:15:04 +0000 (17:15 +0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 28 Apr 2026 06:13:50 +0000 (08:13 +0200)
commitc39f0bc03f84ba64c9144c95714df1dc36150f6d
tree238e5bb41a529fb01d77a5bf7193866bbc2d00f7
parentb32ae47a2b0a1fb4bd4942242847966d9b178222
ALSA: usb-audio: Fix potential leak of pd at parsing UAC3 streams

At parsing UAC3 streams, we allocate a PD object at each time, and
either assign or free it.  But there is a case where the PD object may
be leaked; namely, in __snd_usb_parse_audio_interface() loop, when an
audioformat shares the same endpoint with others, it's put to a link
and returns from snd_usb_add_audio_stream(), but the PD is forgotten
afterwards.  Overall, the treatment of PD object in the parser code is
a bit flaky, and we should be more careful about the object ownership.

This patch tries to fix the above case and improve the code a bit.
The pd object is now managed with the auto-cleanup in the loop, and
the ownership is updated when the pd object gets assigned to the
stream, which guarantees the release of the leftover object.

Fixes: 7edf3b5e6a45 ("ALSA: usb-audio: AudioStreaming Power Domain parsing")
Link: https://patch.msgid.link/20260427151508.12544-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/quirks.c
sound/usb/stream.c
sound/usb/stream.h