From: Julia Lawall Date: Wed, 10 Mar 2010 23:23:52 +0000 (-0800) Subject: drivers/char/mmtimer.c: eliminate useless code X-Git-Tag: v2.6.34-rc2~81 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0fbcae222b8aa3a47034a484e02e7fc14050c783;p=platform%2Fkernel%2Flinux-stable.git drivers/char/mmtimer.c: eliminate useless code The variable x is initialized twice to the same (side effect-free) expression. Drop one initialization. A simplified version of the semantic match that finds this problem is: (http://coccinelle.lip6.fr/) // @forall@ idexpression *x; identifier f!=ERR_PTR; @@ x = f(...) ... when != x ( x = f(...,<+...x...+>,...) | * x = f(...) ) // Stefan observed: The next x = rb_entry(mn->next, struct mmtimer, list); is preceded by a test whether mn->next is NULL. Unless that test is redundant too, your patch fixes a potential NULL pointer dereference, introduced by commit cbacdd95 "SGI Altix mmtimer: allow larger number of timers per node" in 2.6.26. Signed-off-by: Julia Lawall Cc: Stefan Richter Cc: Dimitri Sivanich Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c index 918711a..04fd0d8 100644 --- a/drivers/char/mmtimer.c +++ b/drivers/char/mmtimer.c @@ -546,7 +546,7 @@ static void mmtimer_tasklet(unsigned long data) { int nodeid = data; struct mmtimer_node *mn = &timers[nodeid]; - struct mmtimer *x = rb_entry(mn->next, struct mmtimer, list); + struct mmtimer *x; struct k_itimer *t; unsigned long flags;