]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ASoC: wm_adsp: Fix NULL dereference when removing firmware controls
authorRichard Fitzgerald <rf@opensource.cirrus.com>
Thu, 4 Jun 2026 10:12:44 +0000 (11:12 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 8 Jun 2026 17:50:30 +0000 (18:50 +0100)
In wm_adsp_control_remove() check that the priv pointer is not NULL
before attempting to cleanup what it points to.

When cs_dsp creates a control it calls wm_adsp_control_add_cb() so that
wm_adsp can create its own private control data. There are two cases
where private data is not created:

1. The control is a SYSTEM control, so an ALSA control is not created.

2. The codec driver has registered a control_add() callback that
   hides the control, so wm_adsp_control_add() is not called.

When cs_dsp_remove destroys its control list it calls
wm_adsp_control_remove() for each control. But wm_adsp_control_remove()
was attempting to cleanup the private data pointed to by cs_ctl->priv
without checking the pointer for NULL.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: 0700bc2fb94c ("ASoC: wm_adsp: Separate generic cs_dsp_coeff_ctl handling")
Link: https://patch.msgid.link/20260604101244.1402862-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/wm_adsp.c

index a637e22c3929b4c9dfefd03faad27dff1f67c1b5..ca630c9948e49a3d08e4204a68058a8c7e716931 100644 (file)
@@ -679,6 +679,9 @@ static void wm_adsp_control_remove(struct cs_dsp_coeff_ctl *cs_ctl)
 {
        struct wm_coeff_ctl *ctl = cs_ctl->priv;
 
+       if (!ctl)
+               return;
+
        cancel_work_sync(&ctl->work);
 
        kfree(ctl->name);