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

From: wangdich9700

Date: Mon Apr 27 2026 - 03:08:38 EST


From: wangdicheng <wangdicheng@xxxxxxxxxx>

In cx_probe(), the return value of snd_hda_jack_detect_enable_callback()
is ignored. If this function fails (e.g., due to memory allocation
failure), 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 and propagate the error to the probe caller.

Signed-off-by: wangdicheng <wangdicheng@xxxxxxxxxx>
---
sound/hda/codecs/conexant.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/hda/codecs/conexant.c b/sound/hda/codecs/conexant.c
index 3a9717df39b4..4c01c6270bd3 100644
--- a/sound/hda/codecs/conexant.c
+++ b/sound/hda/codecs/conexant.c
@@ -1190,7 +1190,9 @@ static int cx_probe(struct hda_codec *codec, const struct hda_device_id *id)
case 0x14f11f86:
case 0x14f11f87:
spec->is_cx11880_sn6140 = true;
- snd_hda_jack_detect_enable_callback(codec, 0x19, cx_update_headset_mic_vref);
+ err = snd_hda_jack_detect_enable_callback(codec, 0x19, cx_update_headset_mic_vref);
+ if (err < 0)
+ goto error;
break;
}

--
2.25.1