aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiajian Ye <[email protected]>2022-03-24 18:09:23 -0700
committerLinus Torvalds <[email protected]>2022-03-24 19:06:45 -0700
commit56465a38305f22bca3469c2738d7320a0c333e72 (patch)
tree1666df4da4cb92fb76b6084a24831a6b8536f50e
parent59d7cb27d528eae2f060d548dcd14d292b19fda3 (diff)
tools/vm/page_owner_sort.c: add a security check
Add a security check after using malloc() to allocate memory. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Jiajian Ye <[email protected]> Cc: Stephen Rothwell <[email protected]> Cc: Yinan Zhang <[email protected]> Cc: Yixuan Cao <[email protected]> Cc: Zhenliang Wei <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r--tools/vm/page_owner_sort.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/tools/vm/page_owner_sort.c b/tools/vm/page_owner_sort.c
index 79d69c3b84ed..69fb6ca7c0b7 100644
--- a/tools/vm/page_owner_sort.c
+++ b/tools/vm/page_owner_sort.c
@@ -217,7 +217,13 @@ static void add_list(char *buf, int len)
printf("max_size too small??\n");
exit(1);
}
+
list[list_size].txt = malloc(len+1);
+ if (!list[list_size].txt) {
+ printf("Out of memory\n");
+ exit(1);
+ }
+
list[list_size].len = len;
list[list_size].num = 1;
list[list_size].page_num = get_page_num(buf);