[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20190315034415.24085-1-kjlu@umn.edu>
Date: Thu, 14 Mar 2019 22:44:15 -0500
From: Kangjie Lu <kjlu@....edu>
To: kjlu@....edu
Cc: pakki001@....edu, Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>,
Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>, alsa-devel@...a-project.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] sound: soc-pcm: add a check to avoid NULL pointer dereference
In case debugfs_create_u32 fails, the fix frees memory and returns
an error to notify callers.
Signed-off-by: Kangjie Lu <kjlu@....edu>
---
sound/soc/soc-pcm.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 0d5ec68a1e50..a7d88ed8ebb5 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -1231,15 +1231,21 @@ static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe,
list_add(&dpcm->list_be, &fe->dpcm[stream].be_clients);
list_add(&dpcm->list_fe, &be->dpcm[stream].fe_clients);
- dev_dbg(fe->dev, "connected new DPCM %s path %s %s %s\n",
- stream ? "capture" : "playback", fe->dai_link->name,
- stream ? "<-" : "->", be->dai_link->name);
-
#ifdef CONFIG_DEBUG_FS
- if (fe->debugfs_dpcm_root)
+ if (fe->debugfs_dpcm_root) {
dpcm->debugfs_state = debugfs_create_u32(be->dai_link->name, 0644,
fe->debugfs_dpcm_root, &dpcm->state);
+ if (!dpcm->debugfs_state) {
+ kfree(dpcm);
+ return -ENOMEM;
+ }
+ }
#endif
+
+ dev_dbg(fe->dev, "connected new DPCM %s path %s %s %s\n",
+ stream ? "capture" : "playback", fe->dai_link->name,
+ stream ? "<-" : "->", be->dai_link->name);
+
return 1;
}
--
2.17.1
Powered by blists - more mailing lists