* [PATCH] ALSA: hda/cs8409: Fix possible NULL dereference
@ 2024-10-10 22:16 Murad Masimov
2024-10-11 9:14 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Murad Masimov @ 2024-10-10 22:16 UTC (permalink / raw)
To: Jaroslav Kysela
Cc: Murad Masimov, Takashi Iwai, Vitaly Rodionov, linux-sound,
linux-kernel, lvc-project
If snd_hda_gen_add_kctl fails to allocate memory and returns NULL, then
NULL pointer dereference will occur in the next line.
Since dolphin_fixups function is a hda_fixup function which is not supposed
to return any errors, add simple check before dereference, ignore the fail.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 20e507724113 ("ALSA: hda/cs8409: Add support for dolphin")
Signed-off-by: Murad Masimov <m.masimov@maxima.ru>
---
sound/pci/hda/patch_cs8409.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/sound/pci/hda/patch_cs8409.c b/sound/pci/hda/patch_cs8409.c
index 26f3c31600d7..614327218634 100644
--- a/sound/pci/hda/patch_cs8409.c
+++ b/sound/pci/hda/patch_cs8409.c
@@ -1403,8 +1403,9 @@ void dolphin_fixups(struct hda_codec *codec, const struct hda_fixup *fix, int ac
kctrl = snd_hda_gen_add_kctl(&spec->gen, "Line Out Playback Volume",
&cs42l42_dac_volume_mixer);
/* Update Line Out kcontrol template */
- kctrl->private_value = HDA_COMPOSE_AMP_VAL_OFS(DOLPHIN_HP_PIN_NID, 3, CS8409_CODEC1,
- HDA_OUTPUT, CS42L42_VOL_DAC) | HDA_AMP_VAL_MIN_MUTE;
+ if (kctrl)
+ kctrl->private_value = HDA_COMPOSE_AMP_VAL_OFS(DOLPHIN_HP_PIN_NID, 3, CS8409_CODEC1,
+ HDA_OUTPUT, CS42L42_VOL_DAC) | HDA_AMP_VAL_MIN_MUTE;
cs8409_enable_ur(codec, 0);
snd_hda_codec_set_name(codec, "CS8409/CS42L42");
break;
--
2.39.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ALSA: hda/cs8409: Fix possible NULL dereference
2024-10-10 22:16 [PATCH] ALSA: hda/cs8409: Fix possible NULL dereference Murad Masimov
@ 2024-10-11 9:14 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2024-10-11 9:14 UTC (permalink / raw)
To: Murad Masimov
Cc: Jaroslav Kysela, Takashi Iwai, Vitaly Rodionov, linux-sound,
linux-kernel, lvc-project
On Fri, 11 Oct 2024 00:16:45 +0200,
Murad Masimov wrote:
>
> If snd_hda_gen_add_kctl fails to allocate memory and returns NULL, then
> NULL pointer dereference will occur in the next line.
>
> Since dolphin_fixups function is a hda_fixup function which is not supposed
> to return any errors, add simple check before dereference, ignore the fail.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: 20e507724113 ("ALSA: hda/cs8409: Add support for dolphin")
> Signed-off-by: Murad Masimov <m.masimov@maxima.ru>
Thanks, applied.
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-10-11 9:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-10 22:16 [PATCH] ALSA: hda/cs8409: Fix possible NULL dereference Murad Masimov
2024-10-11 9:14 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox