Commit 728385c4 authored by Julia Lawall's avatar Julia Lawall Committed by Mauro Carvalho Chehab

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: default avatarJulia Lawall <julia@diku.dk>
Acked-by: default avatarMuralidharan Karicheri <m-karicheri2@ti.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 4e1af31a
...@@ -384,7 +384,7 @@ static int vpif_get_std_info(struct channel_obj *ch) ...@@ -384,7 +384,7 @@ static int vpif_get_std_info(struct channel_obj *ch)
int index; int index;
std_info->stdid = vid_ch->stdid; std_info->stdid = vid_ch->stdid;
if (!std_info) if (!std_info->stdid)
return -1; return -1;
for (index = 0; index < ARRAY_SIZE(ch_params); index++) { for (index = 0; index < ARRAY_SIZE(ch_params); index++) {
......
...@@ -1011,8 +1011,6 @@ static int snd_card_saa7134_new_mixer(snd_card_saa7134_t * chip) ...@@ -1011,8 +1011,6 @@ static int snd_card_saa7134_new_mixer(snd_card_saa7134_t * chip)
unsigned int idx; unsigned int idx;
int err, addr; int err, addr;
if (snd_BUG_ON(!chip))
return -EINVAL;
strcpy(card->mixername, "SAA7134 Mixer"); strcpy(card->mixername, "SAA7134 Mixer");
for (idx = 0; idx < ARRAY_SIZE(snd_saa7134_volume_controls); idx++) { for (idx = 0; idx < ARRAY_SIZE(snd_saa7134_volume_controls); idx++) {
......
...@@ -693,12 +693,13 @@ static int qcm_start_data(struct uvd *uvd) ...@@ -693,12 +693,13 @@ static int qcm_start_data(struct uvd *uvd)
static void qcm_stop_data(struct uvd *uvd) static void qcm_stop_data(struct uvd *uvd)
{ {
struct qcm *cam = (struct qcm *) uvd->user_data; struct qcm *cam;
int i, j; int i, j;
int ret; int ret;
if ((uvd == NULL) || (!uvd->streaming) || (uvd->dev == NULL)) if ((uvd == NULL) || (!uvd->streaming) || (uvd->dev == NULL))
return; return;
cam = (struct qcm *) uvd->user_data;
ret = qcm_camera_off(uvd); ret = qcm_camera_off(uvd);
if (ret) if (ret)
......
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