lmkd: Fix potential null dereference in hook call

If hooks are enabled in LMKD and kill_info is not supplied to
kill_one_process, there will be a null dereference on kill_info. This
changes validates ki before dereferencing.

Bug: b/210075795
Test: cq
Change-Id: Ie81ca9bdb73a71f16dc5682c8721a557b8b094fb
This commit is contained in:
Kameron Lutes 2022-04-14 17:36:28 +00:00
parent d74b6c0fcc
commit 4c65da8696
1 changed files with 1 additions and 1 deletions

View File

@ -2327,7 +2327,7 @@ static int kill_one_process(struct proc* procp, int min_oom_score, struct kill_i
procp->oomadj, min_oom_score, ki ? ki->max_thrashing : -1);
result = lmkd_free_memory_before_kill_hook(procp, rss_kb / page_k, min_oom_score,
ki->kill_reason);
ki ? (int)ki->kill_reason : -1);
if (result > 0) {
/*
* Memory was freed elsewhere; no need to kill. Note: intentionally do not