ASoC: ams-delta.c: use component after check
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Fri, 27 Oct 2023 00:09:56 +0000 (00:09 +0000)
committerMark Brown <broonie@kernel.org>
Fri, 27 Oct 2023 16:37:34 +0000 (17:37 +0100)
static void cx81801_close()
{
...
(A) struct snd_soc_dapm_context *dapm = &component->card->dapm;
...
(B) if (!component)
return;
}

(A) uses component before NULL check (B). This patch moves it after (B).

Fixes: d0fdfe34080c ("ASoC: cx20442: replace codec to component")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/3e608474-e99a-4866-ae98-3054a4221f09@moroto.mountain
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87ttqdq623.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/ti/ams-delta.c

index b32cc03dc1c2a1f831095169da39be91d6c6c31c..76bda188e9921738875561a0a3aee2bdac60f1fd 100644 (file)
@@ -301,7 +301,7 @@ static int cx81801_open(struct tty_struct *tty)
 static void cx81801_close(struct tty_struct *tty)
 {
        struct snd_soc_component *component = tty->disc_data;
-       struct snd_soc_dapm_context *dapm = &component->card->dapm;
+       struct snd_soc_dapm_context *dapm;
 
        del_timer_sync(&cx81801_timer);
 
@@ -313,6 +313,8 @@ static void cx81801_close(struct tty_struct *tty)
 
        v253_ops.close(tty);
 
+       dapm = &component->card->dapm;
+
        /* Revert back to default audio input/output constellation */
        snd_soc_dapm_mutex_lock(dapm);