From: Takashi Iwai <tiwai@suse.de>
To: Deepanshu Kartikey <kartikey406@gmail.com>
Cc: zonque@gmail.com, perex@perex.cz, tiwai@suse.com,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
syzbot+2afd7e71155c7e241560@syzkaller.appspotmail.com,
stable@vger.kernel.org
Subject: Re: [PATCH] ALSA: caiaq: fix usb_dev refcount leak on probe failure
Date: Mon, 27 Apr 2026 14:33:52 +0200 [thread overview]
Message-ID: <875x5cziof.wl-tiwai@suse.de> (raw)
In-Reply-To: <20260426001934.70813-1-kartikey406@gmail.com>
On Sun, 26 Apr 2026 02:19:34 +0200,
Deepanshu Kartikey wrote:
>
> create_card() takes a reference on the USB device with usb_get_dev()
> and stores the matching usb_put_dev() in card_free(), which is
> installed as the snd_card's ->private_free destructor.
>
> However, ->private_free is only assigned near the end of init_card(),
> after several failure points (usb_set_interface(), EP type checks,
> usb_submit_urb(), the EP1_CMD_GET_DEVICE_INFO exchange, and its
> timeout). When any of those fail, init_card() returns an error to
> snd_probe(), which calls snd_card_free(card). Because ->private_free
> is still NULL, card_free() never runs, the usb_get_dev() reference
> is not dropped, and the struct usb_device leaks along with its
> descriptor allocations and device_private.
>
> syzbot reproduces this with a malformed UAC3 device whose only valid
> altsetting is 0; init_card()'s usb_set_interface(usb_dev, 0, 1) call
> fails with -EIO and triggers the leak.
>
> Move the ->private_free assignment into create_card(), immediately
> after usb_get_dev(), so that every error path reaching snd_card_free()
> balances the reference. card_free()'s callees (snd_usb_caiaq_input_free,
> free_urbs, kfree) already tolerate the partially-initialized state
> because the chip private area is zero-initialized by snd_card_new().
>
> Reported-by: syzbot+2afd7e71155c7e241560@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=2afd7e71155c7e241560
> Tested-by: syzbot+2afd7e71155c7e241560@syzkaller.appspotmail.com
> Cc: stable@vger.kernel.org
> Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
Applied now. Thanks.
Takashi
prev parent reply other threads:[~2026-04-27 12:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-26 0:19 [PATCH] ALSA: caiaq: fix usb_dev refcount leak on probe failure Deepanshu Kartikey
2026-04-27 12:33 ` Takashi Iwai [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=875x5cziof.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=kartikey406@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=stable@vger.kernel.org \
--cc=syzbot+2afd7e71155c7e241560@syzkaller.appspotmail.com \
--cc=tiwai@suse.com \
--cc=zonque@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox