lkml.org 
[lkml]   [2021]   [Oct]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] mm/damon: Adjust the size of kbuf array to avoid overflow
Date
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
\
 
 \ /
  Last update: 2021-10-13 13:50    [W:0.109 / U:0.524 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site