From e9769f7cf3527a15aa19c78f3241fdde3dd27fd7 Mon Sep 17 00:00:00 2001 From: Kameron Lutes Date: Thu, 14 Apr 2022 17:36:28 +0000 Subject: [PATCH] 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 Merged-In: Ie81ca9bdb73a71f16dc5682c8721a557b8b094fb --- lmkd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lmkd.cpp b/lmkd.cpp index db5c762..47f5229 100644 --- a/lmkd.cpp +++ b/lmkd.cpp @@ -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