* [PATCH 0/3] Remove potential NULL dereference
@ 2010-08-27 5:57 Julia Lawall
2010-08-27 5:57 ` [PATCH 1/3] drivers/media/video/em28xx: " Julia Lawall
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Julia Lawall @ 2010-08-27 5:57 UTC (permalink / raw)
To: linux-kernel; +Cc: kernel-janitors
These patches find a case where there is a dereference before a NULL test
and either move the dereference after the NULL test, or eliminate the NULL
test if it seems unnnecessary.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] drivers/media/video/em28xx: Remove potential NULL dereference
2010-08-27 5:57 [PATCH 0/3] Remove potential NULL dereference Julia Lawall
@ 2010-08-27 5:57 ` Julia Lawall
2010-08-27 5:57 ` [PATCH 2/3] drivers/dma: " Julia Lawall
2010-08-27 5:57 ` [PATCH 3/3] drivers/staging/tm6000: " Julia Lawall
2 siblings, 0 replies; 4+ messages in thread
From: Julia Lawall @ 2010-08-27 5:57 UTC (permalink / raw)
To: Mauro Carvalho Chehab; +Cc: kernel-janitors, linux-media, linux-kernel
If the NULL test is necessary, the initialization involving a dereference of
the tested value should be moved after the NULL test.
The sematic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
type T;
expression E;
identifier i,fld;
statement S;
@@
- T i = E->fld;
+ T i;
... when != E
when != i
if (E == NULL) S
+ i = E->fld;
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
---
drivers/media/video/em28xx/em28xx-video.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 7b9ec6e..95a4b60 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -277,12 +277,13 @@ static void em28xx_copy_vbi(struct em28xx *dev,
{
void *startwrite, *startread;
int offset;
- int bytesperline = dev->vbi_width;
+ int bytesperline;
if (dev == NULL) {
em28xx_isocdbg("dev is null\n");
return;
}
+ bytesperline = dev->vbi_width;
if (dma_q == NULL) {
em28xx_isocdbg("dma_q is null\n");
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/3] drivers/dma: Remove potential NULL dereference
2010-08-27 5:57 [PATCH 0/3] Remove potential NULL dereference Julia Lawall
2010-08-27 5:57 ` [PATCH 1/3] drivers/media/video/em28xx: " Julia Lawall
@ 2010-08-27 5:57 ` Julia Lawall
2010-08-27 5:57 ` [PATCH 3/3] drivers/staging/tm6000: " Julia Lawall
2 siblings, 0 replies; 4+ messages in thread
From: Julia Lawall @ 2010-08-27 5:57 UTC (permalink / raw)
To: Dan Williams; +Cc: kernel-janitors, linux-kernel
In each case, it appears that the NULL test is not necessary. In the first
case, the function pl08x_fill_llis_for_desc is only called in a case where
its argument is computed using container_of. In the second case, the
function pl08x_tasklet is only used as the second argument of tasklet_init,
from which its argument should be the third argument of tasklet_init. But
that value is not NULL at the point of calling tasklet_init, in
pl08x_dma_init_virtual_channels.
The sematic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
type T;
expression E;
identifier i,fld;
statement S;
@@
- T i = E->fld;
+ T i;
... when != E
when != i
if (E == NULL) S
+ i = E->fld;
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
---
drivers/dma/amba-pl08x.c | 8 --------
1 file changed, 8 deletions(-)
diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c
index fc5aaeb..ac675d2 100644
--- a/drivers/dma/amba-pl08x.c
+++ b/drivers/dma/amba-pl08x.c
@@ -626,11 +626,6 @@ static int pl08x_fill_llis_for_desc(struct pl08x_driver_data *pl08x,
struct lli *llis_va;
struct lli *llis_bus;
- if (!txd) {
- dev_err(&pl08x->adev->dev, "%s no descriptor\n", __func__);
- return 0;
- }
-
txd->llis_va = dma_pool_alloc(pl08x->pool, GFP_KERNEL,
&txd->llis_bus);
if (!txd->llis_va) {
@@ -1033,9 +1028,6 @@ static void pl08x_tasklet(unsigned long data)
struct pl08x_driver_data *pl08x = plchan->host;
unsigned long flags;
- if (!plchan)
- BUG();
-
spin_lock_irqsave(&plchan->lock, flags);
if (plchan->at) {
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 3/3] drivers/staging/tm6000: Remove potential NULL dereference
2010-08-27 5:57 [PATCH 0/3] Remove potential NULL dereference Julia Lawall
2010-08-27 5:57 ` [PATCH 1/3] drivers/media/video/em28xx: " Julia Lawall
2010-08-27 5:57 ` [PATCH 2/3] drivers/dma: " Julia Lawall
@ 2010-08-27 5:57 ` Julia Lawall
2 siblings, 0 replies; 4+ messages in thread
From: Julia Lawall @ 2010-08-27 5:57 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: kernel-janitors, devel, linux-kernel
If the NULL test is necessary, the initialization involving a dereference of
the tested value should be moved after the NULL test.
The sematic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
type T;
expression E;
identifier i,fld;
statement S;
@@
- T i = E->fld;
+ T i;
... when != E
when != i
if (E == NULL) S
+ i = E->fld;
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
---
drivers/staging/tm6000/tm6000-alsa.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/tm6000/tm6000-alsa.c b/drivers/staging/tm6000/tm6000-alsa.c
index 087137d..a06b3c6 100644
--- a/drivers/staging/tm6000/tm6000-alsa.c
+++ b/drivers/staging/tm6000/tm6000-alsa.c
@@ -426,11 +426,12 @@ error:
static int tm6000_audio_fini(struct tm6000_core *dev)
{
- struct snd_tm6000_card *chip = dev->adev;
+ struct snd_tm6000_card *chip;
if (!dev)
return 0;
+ chip = dev->adev;
if (!chip)
return 0;
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-08-27 5:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-27 5:57 [PATCH 0/3] Remove potential NULL dereference Julia Lawall
2010-08-27 5:57 ` [PATCH 1/3] drivers/media/video/em28xx: " Julia Lawall
2010-08-27 5:57 ` [PATCH 2/3] drivers/dma: " Julia Lawall
2010-08-27 5:57 ` [PATCH 3/3] drivers/staging/tm6000: " Julia Lawall
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®