lists.zerezo.com
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[2.6 patch] gspca.c:dev_open(): fix use of uninitialized variable
- Date: Thu, 28 Aug 2008 01:02:53 +0300
- From: Adrian Bunk <bunk@xxxxxxxxxx>
- Subject: [2.6 patch] gspca.c:dev_open(): fix use of uninitialized variable
If we got through dev_open() without any error condition setting "ret"
to a non-zero value, and with "gspca_dev->users != 0" then "ret" should
be set to 0, not some random value.
Reported-by: Adrian Bunk <bunk@xxxxxxxxxx>
Signed-off-by: Adrian Bunk <bunk@xxxxxxxxxx>
---
drivers/media/video/gspca/gspca.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
004e7a80e3635b7198475d95189697bb0f3e8d2c
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c
index 15d302b..e737307 100644
--- a/drivers/media/video/gspca/gspca.c
+++ b/drivers/media/video/gspca/gspca.c
@@ -716,87 +716,87 @@ static int vidioc_try_fmt_vid_cap(struct file *file,
static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_format *fmt)
{
struct gspca_dev *gspca_dev = priv;
int ret;
if (mutex_lock_interruptible(&gspca_dev->queue_lock))
return -ERESTARTSYS;
ret = try_fmt_vid_cap(gspca_dev, fmt);
if (ret < 0)
goto out;
if (gspca_dev->nframes != 0
&& fmt->fmt.pix.sizeimage > gspca_dev->frsz) {
ret = -EINVAL;
goto out;
}
if (ret == gspca_dev->curr_mode) {
ret = 0;
goto out; /* same mode */
}
if (gspca_dev->streaming) {
ret = -EBUSY;
goto out;
}
gspca_dev->width = fmt->fmt.pix.width;
gspca_dev->height = fmt->fmt.pix.height;
gspca_dev->pixfmt = fmt->fmt.pix.pixelformat;
gspca_dev->curr_mode = ret;
ret = 0;
out:
mutex_unlock(&gspca_dev->queue_lock);
return ret;
}
static int dev_open(struct inode *inode, struct file *file)
{
struct gspca_dev *gspca_dev;
- int ret;
+ int ret = 0;
PDEBUG(D_STREAM, "%s open", current->comm);
gspca_dev = (struct gspca_dev *) video_devdata(file);
if (mutex_lock_interruptible(&gspca_dev->queue_lock))
return -ERESTARTSYS;
if (!gspca_dev->present) {
ret = -ENODEV;
goto out;
}
/* if not done yet, initialize the sensor */
if (gspca_dev->users == 0) {
if (mutex_lock_interruptible(&gspca_dev->usb_lock)) {
ret = -ERESTARTSYS;
goto out;
}
ret = gspca_dev->sd_desc->open(gspca_dev);
mutex_unlock(&gspca_dev->usb_lock);
if (ret != 0) {
PDEBUG(D_ERR|D_CONF, "init device failed %d", ret);
goto out;
}
} else if (gspca_dev->users > 4) { /* (arbitrary value) */
ret = -EBUSY;
goto out;
}
gspca_dev->users++;
file->private_data = gspca_dev;
#ifdef GSPCA_DEBUG
/* activate the v4l2 debug */
if (gspca_debug & D_V4L2)
gspca_dev->vdev.debug |= 3;
else
gspca_dev->vdev.debug &= ~3;
#endif
out:
mutex_unlock(&gspca_dev->queue_lock);
if (ret != 0)
PDEBUG(D_ERR|D_STREAM, "open failed err %d", ret);
else
PDEBUG(D_STREAM, "open done");
return ret;
}
--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list