From b717ef00ea59bc095a608597ebeb5d315baff863 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Thu, 21 Nov 2019 12:55:32 -0600 Subject: [PATCH] ASoC: SOF: topology: fix possible dereference reported by cppcheck sound/soc/sof/topology.c:141:36: warning: Either the condition '!swidget' is redundant or there is possible null pointer dereference: swidget. [nullPointerRedundantCheck] struct snd_soc_component *scomp = swidget->scomp; ^ sound/soc/sof/topology.c:146:6: note: Assuming that condition '!swidget' is not redundant if (!swidget) ^ sound/soc/sof/topology.c:141:36: note: Null pointer dereference struct snd_soc_component *scomp = swidget->scomp; Signed-off-by: Pierre-Louis Bossart --- sound/soc/sof/topology.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index 987a781a2cd5..1ae06a1f9b0b 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -138,7 +138,7 @@ static int sof_keyword_dapm_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, int event) { struct snd_sof_widget *swidget = w->dobj.private; - struct snd_soc_component *scomp = swidget->scomp; + struct snd_soc_component *scomp; int stream = SNDRV_PCM_STREAM_CAPTURE; struct snd_sof_pcm *spcm; int ret = 0; @@ -146,6 +146,8 @@ static int sof_keyword_dapm_event(struct snd_soc_dapm_widget *w, if (!swidget) return 0; + scomp = swidget->scomp; + dev_dbg(scomp->dev, "received event %d for widget %s\n", event, w->name);