public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* gspca: fix vidioc_s_jpegcomp locking
@ 2008-12-09 21:58 Jim Paris
  2008-12-09 21:59 ` Hans de Goede
  0 siblings, 1 reply; 4+ messages in thread
From: Jim Paris @ 2008-12-09 21:58 UTC (permalink / raw)
  To: Jean-Francois Moine; +Cc: video4linux-list

This locking looked wrong.

-jim

--

gspca: fix vidioc_s_jpegcomp locking

Signed-off-by: Jim Paris <jim@jtan.com>

diff -r b50857fea6df linux/drivers/media/video/gspca/gspca.c
--- a/linux/drivers/media/video/gspca/gspca.c	Tue Dec 09 16:20:31 2008 -0500
+++ b/linux/drivers/media/video/gspca/gspca.c	Tue Dec 09 16:55:39 2008 -0500
@@ -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:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: gspca: fix vidioc_s_jpegcomp locking
  2008-12-09 21:58 gspca: fix vidioc_s_jpegcomp locking Jim Paris
@ 2008-12-09 21:59 ` Hans de Goede
  2008-12-09 22:08   ` Jim Paris
  0 siblings, 1 reply; 4+ messages in thread
From: Hans de Goede @ 2008-12-09 21:59 UTC (permalink / raw)
  To: Jim Paris; +Cc: video4linux-list

Jim Paris wrote:
> 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


> -jim
> 
> --
> 
> gspca: fix vidioc_s_jpegcomp locking
> 
> Signed-off-by: Jim Paris <jim@jtan.com>
> 
> diff -r b50857fea6df linux/drivers/media/video/gspca/gspca.c
> --- a/linux/drivers/media/video/gspca/gspca.c	Tue Dec 09 16:20:31 2008 -0500
> +++ b/linux/drivers/media/video/gspca/gspca.c	Tue Dec 09 16:55:39 2008 -0500
> @@ -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:video4linux-list-request@redhat.com?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/video4linux-list
> 

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: gspca: fix vidioc_s_jpegcomp locking
  2008-12-09 21:59 ` Hans de Goede
@ 2008-12-09 22:08   ` Jim Paris
  2008-12-10  8:25     ` Hans de Goede
  0 siblings, 1 reply; 4+ messages in thread
From: Jim Paris @ 2008-12-09 22:08 UTC (permalink / raw)
  To: Hans de Goede; +Cc: video4linux-list

Hans de Goede wrote:
> Jim Paris wrote:
>> 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.

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

>> gspca: fix vidioc_s_jpegcomp locking
>>
>> Signed-off-by: Jim Paris <jim@jtan.com>
>>
>> diff -r b50857fea6df linux/drivers/media/video/gspca/gspca.c
>> --- a/linux/drivers/media/video/gspca/gspca.c	Tue Dec 09 16:20:31 2008 -0500
>> +++ b/linux/drivers/media/video/gspca/gspca.c	Tue Dec 09 16:55:39 2008 -0500
>> @@ -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:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: gspca: fix vidioc_s_jpegcomp locking
  2008-12-09 22:08   ` Jim Paris
@ 2008-12-10  8:25     ` Hans de Goede
  0 siblings, 0 replies; 4+ messages in thread
From: Hans de Goede @ 2008-12-10  8:25 UTC (permalink / raw)
  To: Jim Paris; +Cc: video4linux-list

Jim Paris wrote:
> Hans de Goede wrote:
>> Jim Paris wrote:
>>> 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.
> 
> 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.
> 

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:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-12-10  8:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-09 21:58 gspca: fix vidioc_s_jpegcomp locking Jim Paris
2008-12-09 21:59 ` Hans de Goede
2008-12-09 22:08   ` Jim Paris
2008-12-10  8:25     ` Hans de Goede

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox