Re: [PATCH] ALSA: hda/conexant: Fix missing error check for jack detection
From: Takashi Iwai
Date: Mon Apr 27 2026 - 08:45:25 EST
On Mon, 27 Apr 2026 09:07:39 +0200,
wangdich9700@xxxxxxx wrote:
>
> 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;
The function returns a pointer. Use IS_ERR() and PTR_ERR() to check
and get the error, instead.
Also, don't forget to put Fixes tag.
thanks,
Takashi