linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/9] drivers/char: Eliminate useless code
@ 2010-01-16 15:57 Julia Lawall
  2010-01-17 11:40 ` Stefan Richter
  0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2010-01-16 15:57 UTC (permalink / raw)
  To: linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

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>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 drivers/char/mmtimer.c              |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

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,9 +546,9 @@ 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;
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/9] drivers/char: Eliminate useless code
  2010-01-16 15:57 [PATCH 1/9] drivers/char: Eliminate useless code Julia Lawall
@ 2010-01-17 11:40 ` Stefan Richter
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Richter @ 2010-01-17 11:40 UTC (permalink / raw)
  To: Julia Lawall
  Cc: linux-kernel, kernel-janitors, Dimitri Sivanich, Andrew Morton,
	Linus Torvalds

Julia Lawall wrote:
> The variable x is initialized twice to the same (side effect-free)
> expression.  Drop one initialization.
[...]
> --- a/drivers/char/mmtimer.c
> +++ b/drivers/char/mmtimer.c
> @@ -546,9 +546,9 @@ 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;

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.
-- 
Stefan Richter
-=====-==-=- ---= =---=
http://arcgraph.de/sr/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-01-17 11:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-16 15:57 [PATCH 1/9] drivers/char: Eliminate useless code Julia Lawall
2010-01-17 11:40 ` Stefan Richter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).