]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
ALSA: usb-audio: Fix usb audio refcnt leak when getting spdif
authorXiyu Yang <xiyuyang19@fudan.edu.cn>
Thu, 23 Apr 2020 04:54:19 +0000 (12:54 +0800)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Mon, 25 May 2020 08:41:50 +0000 (10:41 +0200)
commitf43cc9a4fff973a64ecf1f473a30fb1e9c29fe44
tree50b7f83ae22dced6a0c121e3b70c5ec9ef7d6157
parent55d0a81affc2f1195930c3b77463a7a903224329
ALSA: usb-audio: Fix usb audio refcnt leak when getting spdif

BugLink: https://bugs.launchpad.net/bugs/1876361
commit 59e1947ca09ebd1cae147c08c7c41f3141233c84 upstream.

snd_microii_spdif_default_get() invokes snd_usb_lock_shutdown(), which
increases the refcount of the snd_usb_audio object "chip".

When snd_microii_spdif_default_get() returns, local variable "chip"
becomes invalid, so the refcount should be decreased to keep refcount
balanced.

The reference counting issue happens in several exception handling paths
of snd_microii_spdif_default_get(). When those error scenarios occur
such as usb_ifnum_to_if() returns NULL, the function forgets to decrease
the refcnt increased by snd_usb_lock_shutdown(), causing a refcnt leak.

Fix this issue by jumping to "end" label when those error scenarios
occur.

Fixes: 447d6275f0c2 ("ALSA: usb-audio: Add sanity checks for endpoint accesses")
Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/1587617711-13200-1-git-send-email-xiyuyang19@fudan.edu.cn
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
sound/usb/mixer_quirks.c