From db6531f361aeb3ab26698adf228954a6f2ebe966 Mon Sep 17 00:00:00 2001 From: Zidan Wang Date: Fri, 27 Nov 2015 10:53:09 +0800 Subject: [PATCH] MLK-11915-01 ASoC: imx-wm8960: check return value and init codec_np to avoid wild pointer 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 (cherry picked from commit 68021ab9ada4a7f3037993a3887453e12271d4ed) --- sound/soc/fsl/imx-wm8960.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sound/soc/fsl/imx-wm8960.c b/sound/soc/fsl/imx-wm8960.c index f3c398c98553..293c4f8be046 100644 --- a/sound/soc/fsl/imx-wm8960.c +++ b/sound/soc/fsl/imx-wm8960.c @@ -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; -- 2.17.1