V4L/DVB: drivers/media/video: move dereference after NULL test
authorJulia Lawall <julia@diku.dk>
Fri, 12 Mar 2010 09:15:32 +0000 (06:15 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 18 May 2010 03:47:16 +0000 (00:47 -0300)
commit728385c4d31469b9124953f36fb42015435466c9
tree3c761c8d14c1983a24fca0e5bbc1443a97622cf8
parent4e1af31aaaa8cc4a5cc1d894bdf04dfc7450d47f
V4L/DVB: drivers/media/video: move dereference after NULL test

In quickcam_messenger.c, if the NULL test on uvd is needed, then the
dereference should be after the NULL test.

In vpif_display.c, std_info is initialized to the address of a structure
field.  This seems unlikely to be NULL.  Test std_info->stdid instead.

In saa7134-alsa.c, the function is only called from one place, where the
chip argument has already been dereferenced.  On the other hand, if it
should be kept, then card should be initialized after it.

A simplified version of the semantic match that detects this problem is as
follows (http://coccinelle.lip6.fr/):

// <smpl>
@match exists@
expression x, E;
identifier fld;
@@

* x->fld
  ... when != \(x = E\|&x\)
* x == NULL
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Acked-by: Muralidharan Karicheri <m-karicheri2@ti.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/davinci/vpif_display.c
drivers/media/video/saa7134/saa7134-alsa.c
drivers/media/video/usbvideo/quickcam_messenger.c