[PATCH] ALSA: usb-audio: Fix usb audio refcnt leak when getting spdif

Takashi Iwai tiwai at suse.de
Thu Apr 23 09:11:10 CEST 2020


On Thu, 23 Apr 2020 06:54:19 +0200,
Xiyu Yang wrote:
> 
> 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.
> 
> Signed-off-by: Xiyu Yang <xiyuyang19 at fudan.edu.cn>
> Signed-off-by: Xin Tan <tanxin.ctf at gmail.com>

Applied now (with Cc-to-stable and Fixes tags).


thanks,

Takashi


More information about the Alsa-devel mailing list