diff mbox

[for,v3.6] v4l2-dev.c: Move video_put() after debug printk

Message ID 1343303944-2652-1-git-send-email-elezegarcia@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ezequiel Garcia July 26, 2012, 11:59 a.m. UTC
It is possible that video_put() releases video_device struct,
provoking a panic when debug printk wants to get video_device node name.

Signed-off-by: Ezequiel Garcia <elezegarcia@gmail.com>
---
 drivers/media/video/v4l2-dev.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

Comments

Hans Verkuil July 26, 2012, 12:06 p.m. UTC | #1
On Thu 26 July 2012 13:59:04 Ezequiel Garcia wrote:
> It is possible that video_put() releases video_device struct,
> provoking a panic when debug printk wants to get video_device node name.
> 
> Signed-off-by: Ezequiel Garcia <elezegarcia@gmail.com>

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

Good catch!

Regards,

	Hans

> ---
>  drivers/media/video/v4l2-dev.c |   12 ++++++------
>  1 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
> index af70f93..3210fd5 100644
> --- a/drivers/media/video/v4l2-dev.c
> +++ b/drivers/media/video/v4l2-dev.c
> @@ -478,12 +478,12 @@ static int v4l2_open(struct inode *inode, struct file *filp)
>  	}
>  
>  err:
> -	/* decrease the refcount in case of an error */
> -	if (ret)
> -		video_put(vdev);
>  	if (vdev->debug)
>  		printk(KERN_DEBUG "%s: open (%d)\n",
>  			video_device_node_name(vdev), ret);
> +	/* decrease the refcount in case of an error */
> +	if (ret)
> +		video_put(vdev);
>  	return ret;
>  }
>  
> @@ -500,12 +500,12 @@ static int v4l2_release(struct inode *inode, struct file *filp)
>  		if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags))
>  			mutex_unlock(vdev->lock);
>  	}
> -	/* decrease the refcount unconditionally since the release()
> -	   return value is ignored. */
> -	video_put(vdev);
>  	if (vdev->debug)
>  		printk(KERN_DEBUG "%s: release\n",
>  			video_device_node_name(vdev));
> +	/* decrease the refcount unconditionally since the release()
> +	   return value is ignored. */
> +	video_put(vdev);
>  	return ret;
>  }
>  
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index af70f93..3210fd5 100644
--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -478,12 +478,12 @@  static int v4l2_open(struct inode *inode, struct file *filp)
 	}
 
 err:
-	/* decrease the refcount in case of an error */
-	if (ret)
-		video_put(vdev);
 	if (vdev->debug)
 		printk(KERN_DEBUG "%s: open (%d)\n",
 			video_device_node_name(vdev), ret);
+	/* decrease the refcount in case of an error */
+	if (ret)
+		video_put(vdev);
 	return ret;
 }
 
@@ -500,12 +500,12 @@  static int v4l2_release(struct inode *inode, struct file *filp)
 		if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags))
 			mutex_unlock(vdev->lock);
 	}
-	/* decrease the refcount unconditionally since the release()
-	   return value is ignored. */
-	video_put(vdev);
 	if (vdev->debug)
 		printk(KERN_DEBUG "%s: release\n",
 			video_device_node_name(vdev));
+	/* decrease the refcount unconditionally since the release()
+	   return value is ignored. */
+	video_put(vdev);
 	return ret;
 }