[PATCH 6.6 v2] ALSA: hda: Fix missing pointer check in hda_component_manager_init function
From: Roman Demidov
Date: Tue Sep 15 2026 - 08:24:18 EST
From: Denis Arefev <arefev@xxxxxxxxx>
commit 1cf11d80db5df805b538c942269e05a65bcaf5bc upstream.
The __component_match_add function may assign the 'matchptr' pointer
the value ERR_PTR(-ENOMEM), which will subsequently be dereferenced.
The call stack leading to the error looks like this:
hda_component_manager_init
|-> component_match_add
|-> component_match_add_release
|-> __component_match_add ( ... ,**matchptr, ... )
|-> *matchptr = ERR_PTR(-ENOMEM); // assign
|-> component_master_add_with_match( ... match)
|-> component_match_realloc(match, match->num); // dereference
Add IS_ERR() check to prevent the crash.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: ae7abe36e352 ("ALSA: hda/realtek: Add CS35L41 support for Thinkpad laptops")
Signed-off-by: Denis Arefev <arefev@xxxxxxxxx>
Signed-off-by: Takashi Iwai <tiwai@xxxxxxx>
[Roman: Instead of modifying hda_component_manager_init() (which does not
yet exist in version 6.6), a check needs to be added to the
cs35l41_generic_fixup() function—the very function introduced by the
offending commit, which calls component_match_add() without verifying its
successful completion. A check should also be added to
tas2781_generic_fixup]
Signed-off-by: Roman Demidov <roman.demidov.nn@xxxxxxxxx>
---
Backport fix for CVE-2025-40097
v2: 6.6 is missing 1cf11d80db5d ("ALSA: hda: Fix missing pointer check in
hda_component_manager_init function") as well, and it is the newer tree,
so 6.1 cannot go first here.
A 6.6 version also needs one more hunk than this: 6.6 has a second
unguarded component_match_add() in tas2781_generic_fixup() alongside the
cs35l41_generic_fixup() one.
Send a v2 covering 6.6, both call sites, and 6.1
as Sasha Levin <sashal@xxxxxxxxxx> suggested.
sound/pci/hda/patch_realtek.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 937f3fdbab25..a020e824fbb2 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -7052,6 +7052,11 @@ static void cs35l41_generic_fixup(struct hda_codec *cdc, int action, const char
spec->comps[i].codec = cdc;
component_match_add(dev, &spec->match,
comp_match_cs35l41_dev_name, rec);
+ if (IS_ERR(spec->match)) {
+ codec_err(cdc, "Fail to add component %ld\n",
+ PTR_ERR(spec->match));
+ return;
+ }
}
ret = component_master_add_with_match(dev, &comp_master_ops, spec->match);
if (ret)
@@ -7084,6 +7089,11 @@ static void tas2781_generic_fixup(struct hda_codec *cdc, int action,
spec->comps[0].codec = cdc;
component_match_add(dev, &spec->match,
comp_match_tas2781_dev_name, rec);
+ if (IS_ERR(spec->match)) {
+ codec_err(cdc, "Fail to add component %ld\n",
+ PTR_ERR(spec->match));
+ return;
+ }
ret = component_master_add_with_match(dev, &comp_master_ops,
spec->match);
if (ret)
--
2.53.0