[<prev] [next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.64.1003212217300.12371@ask.diku.dk>
Date: Sun, 21 Mar 2010 22:17:47 +0100 (CET)
From: Julia Lawall <julia@...u.dk>
To: "Digi International, Inc" <Eng.Linux@...i.com>, Eng.Linux@...i.com,
linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: [PATCH] drivers/char/epca.c: eliminate unnecessary NULL test
From: Julia Lawall <julia@...u.dk>
Since chan0 must be a valid pointer at this point, it seems very unlikely
that ch could be NULL. If ch could be NULL, without channel >=
bd->numports, then something else has to be done to avoid the NULL pointer
dereference in the subsequent initialization of bc.
The semantic match that finds the problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@r exists@
expression E, E1;
identifier f;
statement S1,S3;
iterator iter;
@@
if ((E == NULL && ...) || ...)
{
... when != false ((E == NULL && ...) || ...)
when != true ((E != NULL && ...) || ...)
when != iter(E,...) S1
when != E = E1
(
sizeof(E->f)
|
* E->f
)
... when any
return ...;
}
else S3
// </smpl>
Signed-off-by: Julia Lawall <julia@...u.dk>
---
drivers/char/epca.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/char/epca.c b/drivers/char/epca.c
index 17b044a..ea78e6f 100644
--- a/drivers/char/epca.c
+++ b/drivers/char/epca.c
@@ -1500,9 +1500,8 @@ static void doevent(int crd)
lstat = readb(eventbuf + 3);
ch = chan0 + channel;
- if ((unsigned)channel >= bd->numports || !ch) {
- if (channel >= bd->numports)
- ch = chan0;
+ if ((unsigned)channel >= bd->numports) {
+ ch = chan0;
bc = ch->brdchan;
goto next;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists