diff mbox

[4/4] v4l: Release module if subdev registration fails

Message ID 1304170445-11978-5-git-send-email-laurent.pinchart@ideasonboard.com (mailing list archive)
State Accepted
Headers show

Commit Message

Laurent Pinchart April 30, 2011, 1:34 p.m. UTC
If v4l2_device_register_subdev() fails, the reference to the subdev
module taken by the function isn't released. Fix this.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: stable@kernel.org
Acked-by: Hans Verkuil <hverkuil@xs4all.nl>
---
 drivers/media/video/v4l2-device.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

Comments

Laurent Pinchart April 30, 2011, 1:35 p.m. UTC | #1
On Saturday 30 April 2011 15:34:05 Laurent Pinchart wrote:
> If v4l2_device_register_subdev() fails, the reference to the subdev
> module taken by the function isn't released. Fix this.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: stable@kernel.org
> Acked-by: Hans Verkuil <hverkuil@xs4all.nl>

Mauro, if it's not too late, can you pick this patch for 2.6.39 ?

> ---
>  drivers/media/video/v4l2-device.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/media/video/v4l2-device.c
> b/drivers/media/video/v4l2-device.c index 5aeaf87..4aae501 100644
> --- a/drivers/media/video/v4l2-device.c
> +++ b/drivers/media/video/v4l2-device.c
> @@ -155,8 +155,10 @@ int v4l2_device_register_subdev(struct v4l2_device
> *v4l2_dev, sd->v4l2_dev = v4l2_dev;
>  	if (sd->internal_ops && sd->internal_ops->registered) {
>  		err = sd->internal_ops->registered(sd);
> -		if (err)
> +		if (err) {
> +			module_put(sd->owner);
>  			return err;
> +		}
>  	}
> 
>  	/* This just returns 0 if either of the two args is NULL */
> @@ -164,6 +166,7 @@ int v4l2_device_register_subdev(struct v4l2_device
> *v4l2_dev, if (err) {
>  		if (sd->internal_ops && sd->internal_ops->unregistered)
>  			sd->internal_ops->unregistered(sd);
> +		module_put(sd->owner);
>  		return err;
>  	}
diff mbox

Patch

diff --git a/drivers/media/video/v4l2-device.c b/drivers/media/video/v4l2-device.c
index 5aeaf87..4aae501 100644
--- a/drivers/media/video/v4l2-device.c
+++ b/drivers/media/video/v4l2-device.c
@@ -155,8 +155,10 @@  int v4l2_device_register_subdev(struct v4l2_device *v4l2_dev,
 	sd->v4l2_dev = v4l2_dev;
 	if (sd->internal_ops && sd->internal_ops->registered) {
 		err = sd->internal_ops->registered(sd);
-		if (err)
+		if (err) {
+			module_put(sd->owner);
 			return err;
+		}
 	}
 
 	/* This just returns 0 if either of the two args is NULL */
@@ -164,6 +166,7 @@  int v4l2_device_register_subdev(struct v4l2_device *v4l2_dev,
 	if (err) {
 		if (sd->internal_ops && sd->internal_ops->unregistered)
 			sd->internal_ops->unregistered(sd);
+		module_put(sd->owner);
 		return err;
 	}