linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/damon: Adjust the size of kbuf array to avoid overflow
@ 2021-10-13 11:48 Xin Hao
  2021-10-13 14:02 ` SeongJae Park
  0 siblings, 1 reply; 2+ messages in thread
From: Xin Hao @ 2021-10-13 11:48 UTC (permalink / raw)
  To: sjpark; +Cc: xhao, akpm, linux-mm, linux-kernel

In order to avoid the 'count' size space of kbuf array is
used up, but a "\0" is still added.

Signed-off-by: Xin Hao <xhao@linux.alibaba.com>
---
 mm/damon/dbgfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c
index faee070977d8..20c61eed54af 100644
--- a/mm/damon/dbgfs.c
+++ b/mm/damon/dbgfs.c
@@ -247,7 +247,7 @@ static ssize_t dbgfs_kdamond_pid_read(struct file *file,
 	char *kbuf;
 	ssize_t len;
 
-	kbuf = kmalloc(count, GFP_KERNEL);
+	kbuf = kmalloc(count + 1, GFP_KERNEL);
 	if (!kbuf)
 		return -ENOMEM;
 
-- 
2.31.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-13 14:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-13 11:48 [PATCH] mm/damon: Adjust the size of kbuf array to avoid overflow Xin Hao
2021-10-13 14:02 ` SeongJae Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).