media: saa7146: don't use mutex_lock_interruptible in
Subsystems (3)
cover media: saa7146: don't use mutex_lock_interruptible in
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(-)
Signature · 1 line
1.7.10.4
PATCH 1/1 media: saa7146: don't use mutex_lock_interruptible() in device_release().
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>
--- drivers/media/common/saa7146/saa7146_fops.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/common/saa7146/saa7146_fops.c +1 -2
@@ -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 )
Signature · 1 line
1.7.10.4
Re: [PATCH 1/1] media: saa7146: don't use mutex_lock_interruptible() in device_release().
Quoted 4 lines · On Tue December 11 2012 04:05:28 Cyril Roelandt wrote:
Use uninterruptible
mutex_lockin therelease()file op to make sure all resources are properly freed when a process is being terminated. Returning-ERESTARTSYShas no effect for a terminating process and this may cause driver resources not to be released.
Thanks!
Hans
Quoted 44 lines
This was found using the following semantic patch (http://coccinelle.lip6.fr/):
<spml>
@r@
identifier fops;
identifierrelease_func;
@@
static const structv4l2_file_operationsfops = {
.release =release_func
};@depends on r@
identifier r.release_func;
expression E;
@@
static intrelease_func(...)
{
...
- if (mutex_lock_interruptible(E)) return-ERESTARTSYS;
+mutex_lock(E);
...
}
</spml>Signed-off-by Cyril Roelandt <[email protected]>--- drivers/media/common/saa7146/saa7146_fops.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/media/common/saa7146/saa7146_fops.c +1
-2@@ -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 )