Skip to content

Commit

Permalink
tools/vm/page_owner_sort.c: add a security check
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Leo2022Leo authored and torvalds committed Mar 25, 2022
1 parent 59d7cb2 commit 56465a3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tools/vm/page_owner_sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 56465a3

Please sign in to comment.