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); } } }