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 <pierre-louis.bossart@linux.intel.com>
This commit is contained in:
Pierre-Louis Bossart 2019-11-21 12:55:32 -06:00 committed by Pierre Bossart
parent 67d5328f9f
commit b717ef00ea

View File

@ -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);