diff mbox

[3.0.y+,media] Avoid sysfs oops when an rc_dev's raw device is absent

Message ID 5020CAB4.2080607@paradise.net.nz (mailing list archive)
State New, archived
Headers show

Commit Message

Douglas Bagnall Aug. 7, 2012, 7:58 a.m. UTC
Ben Hutchings wrote: 
> This returns without unlocking dev->lock, which isn't much of an
> improvement.  Please get that fixed in mainline, and then I can apply
> both of the changes to 3.2.y at once.

Oh dear. Quite right. Sorry. Thanks.

Douglas

Comments

Herton Ronaldo Krzesinski Aug. 7, 2012, 4:10 p.m. UTC | #1
On Tue, Aug 07, 2012 at 07:58:44PM +1200, Douglas Bagnall wrote:
> Ben Hutchings wrote: 
> > This returns without unlocking dev->lock, which isn't much of an
> > improvement.  Please get that fixed in mainline, and then I can apply
> > both of the changes to 3.2.y at once.

Thanks for reviewing it Ben.

> 
> Oh dear. Quite right. Sorry. Thanks.
> 
> Douglas

> From c1d4df58efb2d13551586d177bcbb4e9af588618 Mon Sep 17 00:00:00 2001
> From: Douglas Bagnall <douglas@paradise.net.nz>
> Date: Tue, 7 Aug 2012 19:30:36 +1200
> Subject: [PATCH] Unlock the rc_dev lock when the raw device is missing
> 
> As pointed out by Ben Hutchings, after commit 720bb6436, the lock was
> being taken and not released when an rc_dev has a NULL raw device.
> 
> Signed-off-by: Douglas Bagnall <douglas@paradise.net.nz>

As it's desired for stable, this could also have
"Cc: stable@vger.kernel.org" when applied, so it's picked up
"automatically" when lands in mainline. Also nitpicking some more,
may be the patch could have a Reported-by line added.

Acked-by: Herton R. Krzesinski <herton.krzesinski@canonical.com>

> ---
>  drivers/media/rc/rc-main.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
> index cabc19c..dcd45d0 100644
> --- a/drivers/media/rc/rc-main.c
> +++ b/drivers/media/rc/rc-main.c
> @@ -778,9 +778,10 @@ static ssize_t show_protocols(struct device *device,
>  	} else if (dev->raw) {
>  		enabled = dev->raw->enabled_protocols;
>  		allowed = ir_raw_get_allowed_protocols();
> -	} else
> +	} else {
> +		mutex_unlock(&dev->lock);
>  		return -ENODEV;
> -
> +	}
>  	IR_dprintk(1, "allowed - 0x%llx, enabled - 0x%llx\n",
>  		   (long long)allowed,
>  		   (long long)enabled);
> -- 
> 1.7.9.5
>
diff mbox

Patch

From c1d4df58efb2d13551586d177bcbb4e9af588618 Mon Sep 17 00:00:00 2001
From: Douglas Bagnall <douglas@paradise.net.nz>
Date: Tue, 7 Aug 2012 19:30:36 +1200
Subject: [PATCH] Unlock the rc_dev lock when the raw device is missing

As pointed out by Ben Hutchings, after commit 720bb6436, the lock was
being taken and not released when an rc_dev has a NULL raw device.

Signed-off-by: Douglas Bagnall <douglas@paradise.net.nz>
---
 drivers/media/rc/rc-main.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index cabc19c..dcd45d0 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -778,9 +778,10 @@  static ssize_t show_protocols(struct device *device,
 	} else if (dev->raw) {
 		enabled = dev->raw->enabled_protocols;
 		allowed = ir_raw_get_allowed_protocols();
-	} else
+	} else {
+		mutex_unlock(&dev->lock);
 		return -ENODEV;
-
+	}
 	IR_dprintk(1, "allowed - 0x%llx, enabled - 0x%llx\n",
 		   (long long)allowed,
 		   (long long)enabled);
-- 
1.7.9.5