Skip to contentSkip to conversation

staging: lowmemorykiller: remove bogus NULL check

PATCH In review Dan Carpenter 2 participants 2 messages Apr 8, 2016 – Apr 9, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: lowmemorykiller: remove bogus NULL check

The NULL checking here doesn't make sense, so it causes a static checker warning. It turns out that p->mm can't be NULL so the inconsistency is harmless and we should just remove the check.

drivers/staging/android/lowmemorykiller.c +1 -1
index c79f224..24d2745 100644
@@ -131,7 +131,7 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
 		if (!p)
 			continue;
 
-		if (task_lmk_waiting(p) && p->mm &&
+		if (task_lmk_waiting(p) &&
 		    time_before_eq(jiffies, lowmem_deathpending_timeout)) {
 			task_unlock(p);
 			rcu_read_unlock();
Acked-by on v1 1/1
#1 lore raw
Quoted 3 lines · Dan Carpenter

The NULL checking here doesn't make sense, so it causes a static checker warning. It turns out that p->mm can't be NULL so the inconsistency is harmless and we should just remove the check.

Commit 77ed2c5745d9 ("android,lowmemorykiller: Don't abuse TIF_MEMDIE.") replaced test_tsk_thread_flag(p, TIF_MEMDIE) with task_lmk_waiting(p) && p->mm because TIF_MEMDIE is cleared after p->mm became NULL whereas PFA_LMK_WAITING is not cleared after p->mm became NULL.
But p is a thread which is guaranteed to be p->mm != NULL.

Quoted 2 lines
Quoted 15 lines
drivers/staging/android/lowmemorykiller.c +1 -1
index c79f224..24d2745 100644
@@ -131,7 +131,7 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
 		if (!p)
 			continue;
 
-		if (task_lmk_waiting(p) && p->mm &&
+		if (task_lmk_waiting(p) &&
 		    time_before_eq(jiffies, lowmem_deathpending_timeout)) {
 			task_unlock(p);
 			rcu_read_unlock();