lkml.org 
[lkml]   [2019]   [Mar]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] sound: soc-pcm: add a check to avoid NULL pointer dereference
Date
In case debugfs_create_u32 fails, the fix frees memory and returns
an error to notify callers.

Signed-off-by: Kangjie Lu <kjlu@umn.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
\
 
 \ /
  Last update: 2019-03-15 04:45    [W:0.017 / U:0.936 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site