linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/1] media: saa7146: don't use mutex_lock_interruptible in
@ 2012-12-11  3:05 Cyril Roelandt
  2012-12-11  3:05 ` [PATCH 1/1] media: saa7146: don't use mutex_lock_interruptible() in device_release() Cyril Roelandt
  0 siblings, 1 reply; 3+ messages in thread
From: Cyril Roelandt @ 2012-12-11  3:05 UTC (permalink / raw)
  To: linux-kernel
  Cc: kernel-janitors, michael, mchehab, linux-media, Cyril Roelandt

This is the same kind of bug as the one fixed by
ddc43d6dc7df0849fe41b91460fa76145cf87b67 : mutex_lock() must be used in the
device_release file operation in order for all resources to be freed, since
returning -RESTARTSYS has no effect here.

I stole the commit log from Sylwester Nawrocki, who fixed a few of these issues,
since I could not formulate it better.

---

Cyril Roelandt (1):
  media: saa7146: don't use mutex_lock_interruptible() in
    device_release().

 drivers/media/common/saa7146/saa7146_fops.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

-- 
1.7.10.4


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

* [PATCH 1/1] media: saa7146: don't use mutex_lock_interruptible() in device_release().
  2012-12-11  3:05 [PATCH 0/1] media: saa7146: don't use mutex_lock_interruptible in Cyril Roelandt
@ 2012-12-11  3:05 ` Cyril Roelandt
  2012-12-11  7:22   ` Hans Verkuil
  0 siblings, 1 reply; 3+ messages in thread
From: Cyril Roelandt @ 2012-12-11  3:05 UTC (permalink / raw)
  To: linux-kernel
  Cc: kernel-janitors, michael, mchehab, linux-media, Cyril Roelandt

Use uninterruptible mutex_lock in the release() file op to make sure all
resources are properly freed when a process is being terminated. Returning
-ERESTARTSYS has no effect for a terminating process and this may cause driver
resources not to be released.

This was found using the following semantic patch (http://coccinelle.lip6.fr/):

<spml>
@r@
identifier fops;
identifier release_func;
@@
static const struct v4l2_file_operations fops = {
.release = release_func
};

@depends on r@
identifier r.release_func;
expression E;
@@
static int release_func(...)
{
...
- if (mutex_lock_interruptible(E)) return -ERESTARTSYS;
+ mutex_lock(E);
...
}
</spml>

Signed-off-by: Cyril Roelandt <tipecaml@gmail.com>
---
 drivers/media/common/saa7146/saa7146_fops.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/common/saa7146/saa7146_fops.c b/drivers/media/common/saa7146/saa7146_fops.c
index b3890bd..0afe98d 100644
--- a/drivers/media/common/saa7146/saa7146_fops.c
+++ b/drivers/media/common/saa7146/saa7146_fops.c
@@ -265,8 +265,7 @@ static int fops_release(struct file *file)
 
 	DEB_EE("file:%p\n", file);
 
-	if (mutex_lock_interruptible(vdev->lock))
-		return -ERESTARTSYS;
+	mutex_lock(vdev->lock);
 
 	if (vdev->vfl_type == VFL_TYPE_VBI) {
 		if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE)
-- 
1.7.10.4


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

* Re: [PATCH 1/1] media: saa7146: don't use mutex_lock_interruptible() in device_release().
  2012-12-11  3:05 ` [PATCH 1/1] media: saa7146: don't use mutex_lock_interruptible() in device_release() Cyril Roelandt
@ 2012-12-11  7:22   ` Hans Verkuil
  0 siblings, 0 replies; 3+ messages in thread
From: Hans Verkuil @ 2012-12-11  7:22 UTC (permalink / raw)
  To: Cyril Roelandt
  Cc: linux-kernel, kernel-janitors, michael, mchehab, linux-media

On Tue December 11 2012 04:05:28 Cyril Roelandt wrote:
> Use uninterruptible mutex_lock in the release() file op to make sure all
> resources are properly freed when a process is being terminated. Returning
> -ERESTARTSYS has no effect for a terminating process and this may cause driver
> resources not to be released.

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

Thanks!

	Hans

> This was found using the following semantic patch (http://coccinelle.lip6.fr/):
> 
> <spml>
> @r@
> identifier fops;
> identifier release_func;
> @@
> static const struct v4l2_file_operations fops = {
> .release = release_func
> };
> 
> @depends on r@
> identifier r.release_func;
> expression E;
> @@
> static int release_func(...)
> {
> ...
> - if (mutex_lock_interruptible(E)) return -ERESTARTSYS;
> + mutex_lock(E);
> ...
> }
> </spml>
> 
> Signed-off-by: Cyril Roelandt <tipecaml@gmail.com>
> ---
>  drivers/media/common/saa7146/saa7146_fops.c |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/media/common/saa7146/saa7146_fops.c b/drivers/media/common/saa7146/saa7146_fops.c
> index b3890bd..0afe98d 100644
> --- a/drivers/media/common/saa7146/saa7146_fops.c
> +++ b/drivers/media/common/saa7146/saa7146_fops.c
> @@ -265,8 +265,7 @@ static int fops_release(struct file *file)
>  
>  	DEB_EE("file:%p\n", file);
>  
> -	if (mutex_lock_interruptible(vdev->lock))
> -		return -ERESTARTSYS;
> +	mutex_lock(vdev->lock);
>  
>  	if (vdev->vfl_type == VFL_TYPE_VBI) {
>  		if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE)
> 

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

end of thread, other threads:[~2012-12-11  7:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-11  3:05 [PATCH 0/1] media: saa7146: don't use mutex_lock_interruptible in Cyril Roelandt
2012-12-11  3:05 ` [PATCH 1/1] media: saa7146: don't use mutex_lock_interruptible() in device_release() Cyril Roelandt
2012-12-11  7:22   ` 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).