ASoC: kirkwood: Fix potential NULL dereference
authorAleksandr Mishin <amishin@t-argos.ru>
Thu, 28 Mar 2024 17:33:37 +0000 (20:33 +0300)
committerMark Brown <broonie@kernel.org>
Thu, 28 Mar 2024 19:27:59 +0000 (19:27 +0000)
In kirkwood_dma_hw_params() mv_mbus_dram_info() returns NULL if
CONFIG_PLAT_ORION macro is not defined.
Fix this bug by adding NULL check.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: bb6a40fc5a83 ("ASoC: kirkwood: Fix reference to PCM buffer address")
Signed-off-by: Aleksandr Mishin <amishin@t-argos.ru>
Link: https://msgid.link/r/20240328173337.21406-1-amishin@t-argos.ru
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/kirkwood/kirkwood-dma.c

index dd2f806526c1037db6a8425dc5e27f6f263ba2e6..ef00792e1d49a43a354307e6d48294fe86bc1c81 100644 (file)
@@ -182,6 +182,9 @@ static int kirkwood_dma_hw_params(struct snd_soc_component *component,
        const struct mbus_dram_target_info *dram = mv_mbus_dram_info();
        unsigned long addr = substream->runtime->dma_addr;
 
+       if (!dram)
+               return 0;
+
        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
                kirkwood_dma_conf_mbus_windows(priv->io,
                        KIRKWOOD_PLAYBACK_WIN, addr, dram);