From: WenTao Liang <vulab@iscas.ac.cn>
To: perex@perex.cz, tiwai@suse.com
Cc: vulab@iscas.ac.cn, cezary.rojewski@intel.com, kees@kernel.org,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: [PATCH] sound: fix refcount leak in snd_ctl_elem_write_user()
Date: Fri, 12 Jun 2026 10:30:59 +0800 [thread overview]
Message-ID: <20260612023059.16005-1-vulab@iscas.ac.cn> (raw)
snd_ctl_elem_write_user() calls snd_power_ref_and_wait(), which
unconditionally acquires a power reference via snd_power_ref().
If the call returns a negative error code (e.g. when the card is
powering down and wait_event_cmd triggers -ENODEV), the reference
is held but never released. The function then returns the error
without calling snd_power_unref(card), leaking the power reference
count.
Add the missing snd_power_unref(card) on the error path to restore
the reference count balance.
Cc: stable@vger.kernel.org
Fixes: fcc62b19104a ("ALSA: control: Take power_ref lock primarily")
Signed-off-by: WenTao Liang <vulab@iscas.ac.cn>
---
sound/core/control.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sound/core/control.c b/sound/core/control.c
index e3bb26206c39..7b714b5f8d54 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -1408,8 +1408,10 @@ static int snd_ctl_elem_write_user(struct snd_ctl_file *file,
card = file->card;
result = snd_power_ref_and_wait(card);
- if (result < 0)
+ if (result < 0) {
+ snd_power_unref(card);
return result;
+ }
result = snd_ctl_elem_write(card, file, control);
snd_power_unref(card);
if (result < 0)
--
2.50.1 (Apple Git-155)
reply other threads:[~2026-06-12 2:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260612023059.16005-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=cezary.rojewski@intel.com \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=stable@vger.kernel.org \
--cc=tiwai@suse.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
all inboxes | Powered by JetHome®