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>
This commit is contained in:
Susheel Khiani 2015-02-12 19:00:15 +05:30 committed by Jeevan Shriram
parent 2f6130c61d
commit 8e3a1a07e3

View file

@ -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,6 +174,7 @@ void tune_lmk_zone_param(struct zonelist *zonelist, int classzone_idx,
zone->lowmem_reserve[classzone_idx];
}
} else {
if (other_free)
*other_free -=
zone_page_state(zone, NR_FREE_PAGES);
}