ASoC: amd: acp5x-mach:add checks to avoid static analysis warnings
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Mon, 31 Jul 2023 21:37:48 +0000 (16:37 -0500)
committerMark Brown <broonie@kernel.org>
Mon, 31 Jul 2023 22:22:18 +0000 (23:22 +0100)
snd_soc_card_get_codec_dai() can return NULL, but that value is not
checked for, leading to static analysis warnings.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Yaochun Hung <yc.hung@mediatek.com>
Link: https://lore.kernel.org/r/20230731213748.440285-9-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/amd/vangogh/acp5x-mach.c

index 125a8e9..eda4645 100644 (file)
@@ -170,6 +170,9 @@ static int acp5x_nau8821_hw_params(struct snd_pcm_substream *substream,
        struct snd_soc_dai *dai = snd_soc_card_get_codec_dai(card, ACP5X_NAU8821_DAI_NAME);
        int ret, bclk;
 
+       if (!dai)
+               return -EINVAL;
+
        ret = snd_soc_dai_set_sysclk(dai, NAU8821_CLK_FLL_BLK, 0, SND_SOC_CLOCK_IN);
        if (ret < 0)
                dev_err(card->dev, "can't set FS clock %d\n", ret);