Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ALSA: hda/conexant: Fix missing error check for jack detection

In cx_probe(), the return value of snd_hda_jack_detect_enable_callback()
is ignored. This function returns a pointer, and if it fails (e.g., due
to memory allocation failure), it returns an error pointer which must
be checked using IS_ERR().

If the registration fails, the driver continues to probe, but the jack
detection callback will not be registered. This can lead to a kernel
crash later when the driver attempts to handle jack events or accesses
the uninitialized structure.

Check the return value using IS_ERR() and propagate the error via
PTR_ERR() to the probe caller.

Fixes: 7aeb25908648 ("ALSA: hda/conexant: Fix headset auto detect fail in cx8070 and SN6140")
Signed-off-by: wangdicheng <wangdicheng@kylinos.cn>
Link: https://patch.msgid.link/20260428080450.108801-1-wangdich9700@163.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

wangdicheng and committed by
Takashi Iwai
b0e2333a 077c593d

+7 -1
+7 -1
sound/hda/codecs/conexant.c
··· 1175 1175 static int cx_probe(struct hda_codec *codec, const struct hda_device_id *id) 1176 1176 { 1177 1177 struct conexant_spec *spec; 1178 + struct hda_jack_callback *callback; 1178 1179 int err; 1179 1180 1180 1181 codec_info(codec, "%s: BIOS auto-probing.\n", codec->core.chip_name); ··· 1191 1190 case 0x14f11f86: 1192 1191 case 0x14f11f87: 1193 1192 spec->is_cx11880_sn6140 = true; 1194 - snd_hda_jack_detect_enable_callback(codec, 0x19, cx_update_headset_mic_vref); 1193 + callback = snd_hda_jack_detect_enable_callback(codec, 0x19, 1194 + cx_update_headset_mic_vref); 1195 + if (IS_ERR(callback)) { 1196 + err = PTR_ERR(callback); 1197 + goto error; 1198 + } 1195 1199 break; 1196 1200 } 1197 1201