From: Guangshuo Li <lgs201920130244@gmail.com>
To: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Guangshuo Li <lgs201920130244@gmail.com>,
Curtis Malainey <cujomalainey@chromium.org>,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH] ALSA: hwdep: fix NULL dereference on error path
Date: Mon, 13 Apr 2026 01:45:29 +0800 [thread overview]
Message-ID: <20260412174529.2597250-1-lgs201920130244@gmail.com> (raw)
snd_hwdep_new() allocates a hwdep instance first and then allocates
hwdep->dev via snd_device_alloc().
When snd_device_alloc() fails, hwdep->dev remains NULL, because
snd_device_alloc() clears *dev_p before attempting to allocate the
device object. The error path then calls snd_hwdep_free(), which
unconditionally invokes put_device(hwdep->dev).
This may lead to a NULL pointer dereference in put_device().
Fixes: 897c8882df58 ("ALSA: hwdep: Don't embed device")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
sound/core/hwdep.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c
index 09200df2932c..aa35bee8da6b 100644
--- a/sound/core/hwdep.c
+++ b/sound/core/hwdep.c
@@ -343,7 +343,8 @@ static void snd_hwdep_free(struct snd_hwdep *hwdep)
return;
if (hwdep->private_free)
hwdep->private_free(hwdep);
- put_device(hwdep->dev);
+ if (hwdep->dev)
+ put_device(hwdep->dev);
kfree(hwdep);
}
--
2.43.0
next reply other threads:[~2026-04-12 17:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-12 17:45 Guangshuo Li [this message]
2026-04-13 5:22 ` Takashi Iwai
2026-04-13 5:48 ` Guangshuo Li
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=20260412174529.2597250-1-lgs201920130244@gmail.com \
--to=lgs201920130244@gmail.com \
--cc=cujomalainey@chromium.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®