From: Julia Lawall Date: Tue, 15 Dec 2009 02:00:09 +0000 (-0800) Subject: drivers/cpuidle: Move dereference after NULL test X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=faa7b7ddca14887ac037f585d2fac7ca6c57037e;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git drivers/cpuidle: Move dereference after NULL test It does not seem possible that ldev can be NULL, so drop the unnecessary test. If ldev can somehow be NULL, then the initialization of last_idx should be moved below the test. A simplified version of the semantic match that detects this problem is as follows (http://coccinelle.lip6.fr/): // @match exists@ expression x, E; identifier fld; @@ * x->fld ... when != \(x = E\|&x\) * x == NULL // Signed-off-by: Julia Lawall Acked-by: Arjan van de Ven Cc: Ingo Molnar Cc: Venkatesh Pallipadi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/cpuidle/governors/ladder.c b/drivers/cpuidle/governors/ladder.c index a4bec3f919aa..1c1ceb4f218f 100644 --- a/drivers/cpuidle/governors/ladder.c +++ b/drivers/cpuidle/governors/ladder.c @@ -69,9 +69,6 @@ static int ladder_select_state(struct cpuidle_device *dev) int last_residency, last_idx = ldev->last_state_idx; int latency_req = pm_qos_requirement(PM_QOS_CPU_DMA_LATENCY); - if (unlikely(!ldev)) - return 0; - /* Special case when user has set very strict latency requirement */ if (unlikely(latency_req == 0)) { ladder_do_selection(ldev, last_idx, 0);