gspca: fix vidioc_s_jpegcomp locking
This locking looked wrong.
-jim
--
gspca: fix vidioc_s_jpegcomp locking
linux/drivers/media/video/gspca/gspca.c +2 -2
@@ -1320,10 +1320,10 @@struct gspca_dev *gspca_dev = priv;int ret; +if (!gspca_dev->sd_desc->set_jcomp) +return -EINVAL ;if (mutex_lock_interruptible (&gspca_dev->usb_lock))return -ERESTARTSYS ; -if (!gspca_dev->sd_desc->set_jcomp) -return -EINVAL ; ret = gspca_dev->sd_desc->set_jcomp (gspca_dev, jpegcomp);mutex_unlock (&gspca_dev->usb_lock);return ret;
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Quoted 2 lines · Jim Paris
This locking looked wrong.
Hi,
I appreciate the effort, but please do not send patches just because something looks wrong. The original code is perfectly fine. It check if the sub driver supports set_jcomp at all, this check does not need locking.
Regards,
Hans
Quoted 26 lines
-jim
--
gspca: fix
vidioc_s_jpegcomplockingSigned-off-by Jim Paris <[email protected]>diff -r
b50857fea6dflinux/drivers/media/video/gspca/gspca.clinux/drivers/media/video/gspca/gspca.c +2
-3@@ -1320,10 +1320,10 @@struct gspca_dev *gspca_dev = priv;int ret; +if (!gspca_dev->sd_desc->set_jcomp) +return -EINVAL ;if (mutex_lock_interruptible (&gspca_dev->usb_lock))return -ERESTARTSYS ; -if (!gspca_dev->sd_desc->set_jcomp) -return -EINVAL ; ret = gspca_dev->sd_desc->set_jcomp (gspca_dev, jpegcomp);mutex_unlock (&gspca_dev->usb_lock);return ret; --
Quoted 4 lines
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Quoted 10 lines · Hans de Goede
Quoted 2 lines · Jim Paris
This locking looked wrong.
Hi,
I appreciate the effort, but please do not send patches just because something looks wrong. The original code is perfectly fine. It check if the sub driver supports
set_jcompat all, this check does not need locking.
Well, the patch was a request for comments. But please double-check. In the current code, if set_jcomp is NULL, the lock is taken but never released.
I agree that the check does not need locking, which is why my change moved the check outside the lock.
-jim
Quoted 4 lines
Quoted 4 lines
gspca: fix
vidioc_s_jpegcomplockingSigned-off-by Jim Paris <[email protected]>
Quoted 15 lines
Quoted 5 lines
diff -r
b50857fea6dflinux/drivers/media/video/gspca/gspca.clinux/drivers/media/video/gspca/gspca.c +0
-0@@ -1320,10 +1320,10 @@struct gspca_dev *gspca_dev = priv;linux/drivers/media/video/gspca/gspca.c line 1328
Quoted 10 lines
linux/drivers/media/video/gspca/gspca.c +2
-2int ret; +if (!gspca_dev->sd_desc->set_jcomp) +return -EINVAL ;if (mutex_lock_interruptible (&gspca_dev->usb_lock))return -ERESTARTSYS ; -if (!gspca_dev->sd_desc->set_jcomp) -return -EINVAL ; ret = gspca_dev->sd_desc->set_jcomp (gspca_dev, jpegcomp);mutex_unlock (&gspca_dev->usb_lock);return ret;
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Quoted 6 lines · Jim Paris
Quoted 5 lines · Hans de Goede
Quoted 2 lines · Jim Paris
This locking looked wrong.
Hi,
Quoted 9 lines
Quoted 1 line
I appreciate the effort, but please do not send patches just because something looks wrong. The original code is perfectly fine. It check if the sub driver supports
set_jcompat all, this check does not need locking.Well, the patch was a request for comments. But please double-check. In the current code, if
set_jcompis NULL, the lock is taken but never released.I agree that the check does not need locking, which is why my change moved the check outside the lock.
Blergh, sorry I completely misread your patch, somehow reversing what it did in my head.
You are completely right, the original code is wrong, and this patch needs to be applied.
Sorry!
Regards,
Hans
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list