linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] em28xx-video: Swap release order to avoid lock nesting
@ 2013-11-06  8:39 Ricardo Ribalda Delgado
  2013-11-06  9:08 ` Hans Verkuil
  0 siblings, 1 reply; 2+ messages in thread
From: Ricardo Ribalda Delgado @ 2013-11-06  8:39 UTC (permalink / raw)
  To: linux-media; +Cc: Ricardo Ribalda Delgado

vb2_fop_release might take the video queue mutex lock.
In order to avoid nesting mutexes the private mutex is taken after the
fop_release has finished.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/media/usb/em28xx/em28xx-video.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
index 9d10334..b5c3360 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -1663,8 +1663,8 @@ static int em28xx_v4l2_close(struct file *filp)
 
 	em28xx_videodbg("users=%d\n", dev->users);
 
-	mutex_lock(&dev->lock);
 	vb2_fop_release(filp);
+	mutex_lock(&dev->lock);
 
 	if (dev->users == 1) {
 		/* the device is already disconnect,
-- 
1.8.4.rc3


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

* Re: [PATCH] em28xx-video: Swap release order to avoid lock nesting
  2013-11-06  8:39 [PATCH] em28xx-video: Swap release order to avoid lock nesting Ricardo Ribalda Delgado
@ 2013-11-06  9:08 ` Hans Verkuil
  0 siblings, 0 replies; 2+ messages in thread
From: Hans Verkuil @ 2013-11-06  9:08 UTC (permalink / raw)
  To: Ricardo Ribalda Delgado; +Cc: linux-media

On 11/06/13 09:39, Ricardo Ribalda Delgado wrote:
> vb2_fop_release might take the video queue mutex lock.
> In order to avoid nesting mutexes the private mutex is taken after the
> fop_release has finished.
> 
> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
> ---
>  drivers/media/usb/em28xx/em28xx-video.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
> index 9d10334..b5c3360 100644
> --- a/drivers/media/usb/em28xx/em28xx-video.c
> +++ b/drivers/media/usb/em28xx/em28xx-video.c
> @@ -1663,8 +1663,8 @@ static int em28xx_v4l2_close(struct file *filp)
>  
>  	em28xx_videodbg("users=%d\n", dev->users);
>  
> -	mutex_lock(&dev->lock);
>  	vb2_fop_release(filp);
> +	mutex_lock(&dev->lock);
>  
>  	if (dev->users == 1) {
>  		/* the device is already disconnect,
> 

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

Regards,

	Hans

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

end of thread, other threads:[~2013-11-06  9:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-06  8:39 [PATCH] em28xx-video: Swap release order to avoid lock nesting Ricardo Ribalda Delgado
2013-11-06  9:08 ` Hans Verkuil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).