MLK-11915-01 ASoC: imx-wm8960: check return value and init codec_np to avoid wild...
authorZidan Wang <zidan.wang@freescale.com>
Fri, 27 Nov 2015 02:53:09 +0000 (10:53 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:49:17 +0000 (14:49 -0500)
check return value for set_fmt and set_sysclk function, and init
codec_np to avoid wild pointer. Reported by coverity.

Signed-off-by: Zidan Wang <zidan.wang@freescale.com>
(cherry picked from commit 68021ab9ada4a7f3037993a3887453e12271d4ed)

sound/soc/fsl/imx-wm8960.c

index f3c398c..293c4f8 100644 (file)
@@ -315,13 +315,17 @@ static int imx_hifi_hw_free(struct snd_pcm_substream *substream)
        struct snd_soc_card *card = rtd->card;
        struct imx_wm8960_data *data = snd_soc_card_get_drvdata(card);
        bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
+       struct device *dev = card->dev;
+       int ret;
 
        data->is_stream_in_use[tx] = false;
 
        /* Power down PLL to save power*/
        if (data->is_codec_master && !data->is_stream_in_use[!tx]) {
                snd_soc_dai_set_pll(codec_dai, 0, 0, 0, 0);
-               snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF);
+               ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF);
+               if (ret)
+                       dev_warn(dev, "failed to set codec dai fmt: %d\n", ret);
        }
 
        return 0;
@@ -454,7 +458,8 @@ static struct snd_soc_dai_link imx_wm8960_dai[] = {
 
 static int imx_wm8960_probe(struct platform_device *pdev)
 {
-       struct device_node *cpu_np, *codec_np, *gpr_np;
+       struct device_node *cpu_np, *codec_np = NULL;
+       struct device_node *gpr_np;
        struct platform_device *cpu_pdev;
        struct imx_priv *priv = &card_priv;
        struct i2c_client *codec_dev;