summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSusheel Khiani <skhiani@codeaurora.org>2015-02-12 19:00:15 +0530
committerJeevan Shriram <jshriram@codeaurora.org>2016-04-13 11:10:41 -0700
commit8e3a1a07e3bd18b17ac29de14823ee56a7d4bf03 (patch)
treee519a2a907cab833b8b9f80f02033e1cbb7cb38a
parent2f6130c61d0aa147d43b6bb2a2f9b8d2cdd6c239 (diff)
lowmemorykiller: Do proper NULL checks
Pointer other_free is getting dereferenced without performing proper NULL checks which may cause issue. Do proper NULL checks at all points before dereferencing it. Change-Id: I88515703d64730e42598ab16136dcce4c18b099c Signed-off-by: Susheel Khiani <skhiani@codeaurora.org>
-rw-r--r--drivers/staging/android/lowmemorykiller.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
index 752aba43fd7f..11535e3065ac 100644
--- a/drivers/staging/android/lowmemorykiller.c
+++ b/drivers/staging/android/lowmemorykiller.c
@@ -145,7 +145,7 @@ void tune_lmk_zone_param(struct zonelist *zonelist, int classzone_idx,
for_each_zone_zonelist(zone, zoneref, zonelist, MAX_NR_ZONES) {
zone_idx = zonelist_zone_idx(zoneref);
if (zone_idx == ZONE_MOVABLE) {
- if (!use_cma_pages)
+ if (!use_cma_pages && other_free)
*other_free -=
zone_page_state(zone, NR_FREE_CMA_PAGES);
continue;
@@ -160,7 +160,8 @@ void tune_lmk_zone_param(struct zonelist *zonelist, int classzone_idx,
NR_FILE_PAGES)
- zone_page_state(zone, NR_SHMEM);
} else if (zone_idx < classzone_idx) {
- if (zone_watermark_ok(zone, 0, 0, classzone_idx, 0)) {
+ if (zone_watermark_ok(zone, 0, 0, classzone_idx, 0) &&
+ other_free) {
if (!use_cma_pages) {
*other_free -= min(
zone->lowmem_reserve[classzone_idx] +
@@ -173,8 +174,9 @@ void tune_lmk_zone_param(struct zonelist *zonelist, int classzone_idx,
zone->lowmem_reserve[classzone_idx];
}
} else {
- *other_free -=
- zone_page_state(zone, NR_FREE_PAGES);
+ if (other_free)
+ *other_free -=
+ zone_page_state(zone, NR_FREE_PAGES);
}
}
}