simple_lmk: Be extra paranoid if tasks can have no pages

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>
fourteen
Sultan Alsawaf 3 years ago committed by Jenna
parent 6033cfd36e
commit 3e49dbc48e
  1. 2
      drivers/android/simple_lmk.c

@ -191,7 +191,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;
}

Loading…
Cancel
Save