Thread (348 messages) 348 messages, 3 authors, 2021-03-04
STALE1940d REVIEWED: 2 (2M)

[PATCH 5.4 114/340] ASoC: SOF: debug: Fix a potential issue on string buffer termination

From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date: 2021-03-01 22:20:27
Also in: stable
Subsystem: sound, sound - soc layer / dynamic audio power management (asoc), sound - sound open firmware (sof) drivers, the rest · Maintainers: Jaroslav Kysela, Takashi Iwai, Liam Girdwood, Mark Brown, Peter Ujfalusi, Bard Liao, Daniel Baluta, Linus Torvalds

From: Hui Wang <redacted>

[ Upstream commit 9037c3bde65d339017ef41d81cb58069ffc321d4 ]

The function simple_write_to_buffer() doesn't add string termination
at the end of buf, we need to handle it on our own. This change refers
to the function tokenize_input() in debug.c and the function
sof_dfsentry_trace_filter_write() in trace.c.

Fixes: 091c12e1f50c ("ASoC: SOF: debug: add new debugfs entries for IPC flood test")
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Hui Wang <redacted>
Link: https://lore.kernel.org/r/20210208103857.75705-1-hui.wang@canonical.com (local)
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 sound/soc/sof/debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/sof/debug.c b/sound/soc/sof/debug.c
index 5529e8eeca462..08726034ff090 100644
--- a/sound/soc/sof/debug.c
+++ b/sound/soc/sof/debug.c
@@ -135,7 +135,7 @@ static ssize_t sof_dfsentry_write(struct file *file, const char __user *buffer,
 	char *string;
 	int ret;
 
-	string = kzalloc(count, GFP_KERNEL);
+	string = kzalloc(count+1, GFP_KERNEL);
 	if (!string)
 		return -ENOMEM;
 
-- 
2.27.0


Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help