Skip to content

Commit

Permalink
simple_lmk: Be extra paranoid if tasks can have no pages
Browse files Browse the repository at this point in the history
If it's possible for a task to have no pages, then there could be a case
where `pages_found` is zero while `nr_found` isn't, which would cause
the found tasks' locks to never be unlocked, and thus mayhem. We can
change the `pages_found` check to use `nr_found` instead in order to
naturally defend against this scenario, in case it is indeed possible.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Khusika Dhamar Gusti <mail@khusika.com>
  • Loading branch information
kerneltoast authored and Khusika Dhamar Gusti committed Aug 22, 2021
1 parent 0e1eaa3 commit eabe8ac
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/android/simple_lmk.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ static void scan_and_kill(void)

/* Populate the victims array with tasks sorted by adj and then size */
pages_found = find_victims(&nr_found);
if (unlikely(!pages_found)) {
if (unlikely(!nr_found)) {
pr_err("No processes available to kill!\n");
return;
}
Expand Down

0 comments on commit eabe8ac

Please sign in to comment.