Commit 0fbcae22 authored by Julia Lawall's avatar Julia Lawall Committed by Linus Torvalds

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/)

// <smpl>
@forall@
idexpression *x;
identifier f!=ERR_PTR;
@@

x = f(...)
... when != x
(
x = f(...,<+...x...+>,...)
|
* x = f(...)
)
// </smpl>

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: default avatarJulia Lawall <julia@diku.dk>
Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
Cc: Dimitri Sivanich <sivanich@sgi.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 582ef52a
...@@ -546,7 +546,7 @@ static void mmtimer_tasklet(unsigned long data) ...@@ -546,7 +546,7 @@ static void mmtimer_tasklet(unsigned long data)
{ {
int nodeid = data; int nodeid = data;
struct mmtimer_node *mn = &timers[nodeid]; struct mmtimer_node *mn = &timers[nodeid];
struct mmtimer *x = rb_entry(mn->next, struct mmtimer, list); struct mmtimer *x;
struct k_itimer *t; struct k_itimer *t;
unsigned long flags; unsigned long flags;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment