From: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
To: perex@perex.cz, tiwai@suse.de
Cc: linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org,
Sreeraj S Kurup <sreekuttan2156239@gmail.com>
Subject: [PATCH] ALSA: jack: Fix control leak on jack allocation failure
Date: Sun, 15 Nov 2026 10:19:49 +0000 [thread overview]
Message-ID: <20261115101949.2483-1-sreekuttan2156239@gmail.com> (raw)
snd_jack_new() creates an ALSA jack control before allocating the
jack structure.
If the jack structure allocation fails, the function returns
-ENOMEM without removing the previously created control.
Remove the control using snd_ctl_remove() to release the control
and its private data before returning -ENOMEM.
Initialize the control list before removal so that the
private_free callback can safely remove the list entry.
Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
---
sound/core/jack.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/sound/core/jack.c b/sound/core/jack.c
index af2dc2cfbe19..92febcb42a8d 100644
--- a/sound/core/jack.c
+++ b/sound/core/jack.c
@@ -555,8 +555,14 @@ int snd_jack_new(struct snd_card *card, const char *id, int type,
}
jack = kzalloc_obj(struct snd_jack);
- if (jack == NULL)
+ if (!jack) {
+ if (jack_kctl) {
+ INIT_LIST_HEAD(&jack_kctl->list);
+ snd_ctl_remove(card, jack_kctl->kctl);
+ }
+
return -ENOMEM;
+ }
jack->id = kstrdup(id, GFP_KERNEL);
if (jack->id == NULL) {
--
2.55.0
reply other threads:[~2026-11-15 10:20 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=20261115101949.2483-1-sreekuttan2156239@gmail.com \
--to=sreekuttan2156239@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.de \
/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®