[alsa-devel] [PATCH 1/3] ASoC: SOF: topology: fix missing NULL pointer check

Pierre-Louis Bossart pierre-louis.bossart at linux.intel.com
Fri Nov 1 18:09:14 CET 2019


From: Keyon Jie <yang.jie at linux.intel.com>

Add check to avoid possible NULL pointer dereference issue.

This issue was reported by static analysis tools, we didn't face this
issue but we can't rule it out either as a false positive.

Reported-by: Keqiao Zhang <keqiao.zhang at intel.com>
Signed-off-by: Keyon Jie <yang.jie at linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart at linux.intel.com>
---
 sound/soc/sof/topology.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
index e0e2ae734632..d74acb828873 100644
--- a/sound/soc/sof/topology.c
+++ b/sound/soc/sof/topology.c
@@ -150,6 +150,11 @@ static int sof_keyword_dapm_event(struct snd_soc_dapm_widget *w,
 
 	/* get runtime PCM params using widget's stream name */
 	spcm = snd_sof_find_spcm_name(sdev, swidget->widget->sname);
+	if (!spcm) {
+		dev_err(sdev->dev, "error: cannot find PCM for %s\n",
+			swidget->widget->name);
+		return -EINVAL;
+	}
 
 	/* process events */
 	switch (event) {
-- 
2.20.1



More information about the Alsa-devel mailing list