Commit 6c6ee53c authored by Hans de Goede's avatar Hans de Goede Committed by Linus Torvalds

gspca_sn9c20x: Fix NULL pointer dereference

Don't call v4l2_ctrl_g_ctrl on ctrls which the model cam in question
does not have.
Reported-by: default avatarFrank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
[ Taken directly, since Mauro is on vacation ]
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent c5e43b83
...@@ -2070,10 +2070,13 @@ static int sd_start(struct gspca_dev *gspca_dev) ...@@ -2070,10 +2070,13 @@ static int sd_start(struct gspca_dev *gspca_dev)
set_gamma(gspca_dev, v4l2_ctrl_g_ctrl(sd->gamma)); set_gamma(gspca_dev, v4l2_ctrl_g_ctrl(sd->gamma));
set_redblue(gspca_dev, v4l2_ctrl_g_ctrl(sd->blue), set_redblue(gspca_dev, v4l2_ctrl_g_ctrl(sd->blue),
v4l2_ctrl_g_ctrl(sd->red)); v4l2_ctrl_g_ctrl(sd->red));
set_gain(gspca_dev, v4l2_ctrl_g_ctrl(sd->gain)); if (sd->gain)
set_exposure(gspca_dev, v4l2_ctrl_g_ctrl(sd->exposure)); set_gain(gspca_dev, v4l2_ctrl_g_ctrl(sd->gain));
set_hvflip(gspca_dev, v4l2_ctrl_g_ctrl(sd->hflip), if (sd->exposure)
v4l2_ctrl_g_ctrl(sd->vflip)); set_exposure(gspca_dev, v4l2_ctrl_g_ctrl(sd->exposure));
if (sd->hflip)
set_hvflip(gspca_dev, v4l2_ctrl_g_ctrl(sd->hflip),
v4l2_ctrl_g_ctrl(sd->vflip));
reg_w1(gspca_dev, 0x1007, 0x20); reg_w1(gspca_dev, 0x1007, 0x20);
reg_w1(gspca_dev, 0x1061, 0x03); reg_w1(gspca_dev, 0x1061, 0x03);
...@@ -2176,7 +2179,7 @@ static void sd_dqcallback(struct gspca_dev *gspca_dev) ...@@ -2176,7 +2179,7 @@ static void sd_dqcallback(struct gspca_dev *gspca_dev)
struct sd *sd = (struct sd *) gspca_dev; struct sd *sd = (struct sd *) gspca_dev;
int avg_lum; int avg_lum;
if (!v4l2_ctrl_g_ctrl(sd->autogain)) if (sd->autogain == NULL || !v4l2_ctrl_g_ctrl(sd->autogain))
return; return;
avg_lum = atomic_read(&sd->avg_lum); avg_lum = atomic_read(&sd->avg_lum);
......
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