diff options
author | Julia Lawall <julia@diku.dk> | 2009-12-14 21:00:09 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-15 11:53:25 -0500 |
commit | faa7b7ddca14887ac037f585d2fac7ca6c57037e (patch) | |
tree | a44e7785a83a9f778fe3acec2f6aa07630292b23 | |
parent | 471452104b8520337ae2fb48c4e61cd4896e025d (diff) |
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/):
// <smpl>
@match exists@
expression x, E;
identifier fld;
@@
* x->fld
... when != \(x = E\|&x\)
* x == NULL
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Acked-by: Arjan van de Ven <arjan@linux.intel.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/cpuidle/governors/ladder.c | 3 |
1 files changed, 0 insertions, 3 deletions
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) | |||
69 | int last_residency, last_idx = ldev->last_state_idx; | 69 | int last_residency, last_idx = ldev->last_state_idx; |
70 | int latency_req = pm_qos_requirement(PM_QOS_CPU_DMA_LATENCY); | 70 | int latency_req = pm_qos_requirement(PM_QOS_CPU_DMA_LATENCY); |
71 | 71 | ||
72 | if (unlikely(!ldev)) | ||
73 | return 0; | ||
74 | |||
75 | /* Special case when user has set very strict latency requirement */ | 72 | /* Special case when user has set very strict latency requirement */ |
76 | if (unlikely(latency_req == 0)) { | 73 | if (unlikely(latency_req == 0)) { |
77 | ladder_do_selection(ldev, last_idx, 0); | 74 | ladder_do_selection(ldev, last_idx, 0); |