2010-11-22 09:43:16

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] backlight: grab ops_lock before testing bd->ops

According to the comment describing ops_lock in the definition of
struct backlight_device and when comparing with other functions in
backlight.c the mutex must be hold when checking ops to be non-NULL.

Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/video/backlight/backlight.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index e207810..0870329 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -197,12 +197,12 @@ static int backlight_suspend(struct device *dev, pm_message_t state)
{
struct backlight_device *bd = to_backlight_device(dev);

- if (bd->ops->options & BL_CORE_SUSPENDRESUME) {
- mutex_lock(&bd->ops_lock);
+ mutex_lock(&bd->ops_lock);
+ if (bd->ops && bd->ops->options & BL_CORE_SUSPENDRESUME) {
bd->props.state |= BL_CORE_SUSPENDED;
backlight_update_status(bd);
- mutex_unlock(&bd->ops_lock);
}
+ mutex_unlock(&bd->ops_lock);

return 0;
}
@@ -211,12 +211,12 @@ static int backlight_resume(struct device *dev)
{
struct backlight_device *bd = to_backlight_device(dev);

- if (bd->ops->options & BL_CORE_SUSPENDRESUME) {
- mutex_lock(&bd->ops_lock);
+ mutex_lock(&bd->ops_lock);
+ if (bd->ops && bd->ops->options & BL_CORE_SUSPENDRESUME) {
bd->props.state &= ~BL_CORE_SUSPENDED;
backlight_update_status(bd);
- mutex_unlock(&bd->ops_lock);
}
+ mutex_unlock(&bd->ops_lock);

return 0;
}
--
1.7.2.3


2010-11-22 09:59:36

by Richard Purdie

[permalink] [raw]
Subject: Re: [PATCH] backlight: grab ops_lock before testing bd->ops

On Mon, 2010-11-22 at 10:43 +0100, Uwe Kleine-König wrote:
> According to the comment describing ops_lock in the definition of
> struct backlight_device and when comparing with other functions in
> backlight.c the mutex must be hold when checking ops to be non-NULL.
>
> Signed-off-by: Uwe Kleine-König <[email protected]>

Acked-by: Richard Purdie <[email protected]>

> ---
> drivers/video/backlight/backlight.c | 12 ++++++------
> 1 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
> index e207810..0870329 100644
> --- a/drivers/video/backlight/backlight.c
> +++ b/drivers/video/backlight/backlight.c
> @@ -197,12 +197,12 @@ static int backlight_suspend(struct device *dev, pm_message_t state)
> {
> struct backlight_device *bd = to_backlight_device(dev);
>
> - if (bd->ops->options & BL_CORE_SUSPENDRESUME) {
> - mutex_lock(&bd->ops_lock);
> + mutex_lock(&bd->ops_lock);
> + if (bd->ops && bd->ops->options & BL_CORE_SUSPENDRESUME) {
> bd->props.state |= BL_CORE_SUSPENDED;
> backlight_update_status(bd);
> - mutex_unlock(&bd->ops_lock);
> }
> + mutex_unlock(&bd->ops_lock);
>
> return 0;
> }
> @@ -211,12 +211,12 @@ static int backlight_resume(struct device *dev)
> {
> struct backlight_device *bd = to_backlight_device(dev);
>
> - if (bd->ops->options & BL_CORE_SUSPENDRESUME) {
> - mutex_lock(&bd->ops_lock);
> + mutex_lock(&bd->ops_lock);
> + if (bd->ops && bd->ops->options & BL_CORE_SUSPENDRESUME) {
> bd->props.state &= ~BL_CORE_SUSPENDED;
> backlight_update_status(bd);
> - mutex_unlock(&bd->ops_lock);
> }
> + mutex_unlock(&bd->ops_lock);
>
> return 0;
> }

2010-11-22 10:05:38

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH] backlight: grab ops_lock before testing bd->ops

Hello,

On Mon, Nov 22, 2010 at 09:59:07AM +0000, Richard Purdie wrote:
> On Mon, 2010-11-22 at 10:43 +0100, Uwe Kleine-K?nig wrote:
> > According to the comment describing ops_lock in the definition of
> > struct backlight_device and when comparing with other functions in
> > backlight.c the mutex must be hold when checking ops to be non-NULL.
> >
> > Signed-off-by: Uwe Kleine-K?nig <[email protected]>
>
> Acked-by: Richard Purdie <[email protected]>
The problem was introduced by c835ee7f4154992e6cf0674d7ee136f5d36247a4
(that is in 2.6.29-rc1). Is this relevant for stable?

Best regards
Uwe

> > ---
> > drivers/video/backlight/backlight.c | 12 ++++++------
> > 1 files changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
> > index e207810..0870329 100644
> > --- a/drivers/video/backlight/backlight.c
> > +++ b/drivers/video/backlight/backlight.c
> > @@ -197,12 +197,12 @@ static int backlight_suspend(struct device *dev, pm_message_t state)
> > {
> > struct backlight_device *bd = to_backlight_device(dev);
> >
> > - if (bd->ops->options & BL_CORE_SUSPENDRESUME) {
> > - mutex_lock(&bd->ops_lock);
> > + mutex_lock(&bd->ops_lock);
> > + if (bd->ops && bd->ops->options & BL_CORE_SUSPENDRESUME) {
> > bd->props.state |= BL_CORE_SUSPENDED;
> > backlight_update_status(bd);
> > - mutex_unlock(&bd->ops_lock);
> > }
> > + mutex_unlock(&bd->ops_lock);
> >
> > return 0;
> > }
> > @@ -211,12 +211,12 @@ static int backlight_resume(struct device *dev)
> > {
> > struct backlight_device *bd = to_backlight_device(dev);
> >
> > - if (bd->ops->options & BL_CORE_SUSPENDRESUME) {
> > - mutex_lock(&bd->ops_lock);
> > + mutex_lock(&bd->ops_lock);
> > + if (bd->ops && bd->ops->options & BL_CORE_SUSPENDRESUME) {
> > bd->props.state &= ~BL_CORE_SUSPENDED;
> > backlight_update_status(bd);
> > - mutex_unlock(&bd->ops_lock);
> > }
> > + mutex_unlock(&bd->ops_lock);
> >
> > return 0;
> > }
>
>
>

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2010-11-22 18:02:58

by Greg KH

[permalink] [raw]
Subject: Re: [stable] [PATCH] backlight: grab ops_lock before testing bd->ops

On Mon, Nov 22, 2010 at 11:05:32AM +0100, Uwe Kleine-K?nig wrote:
> Hello,
>
> On Mon, Nov 22, 2010 at 09:59:07AM +0000, Richard Purdie wrote:
> > On Mon, 2010-11-22 at 10:43 +0100, Uwe Kleine-K?nig wrote:
> > > According to the comment describing ops_lock in the definition of
> > > struct backlight_device and when comparing with other functions in
> > > backlight.c the mutex must be hold when checking ops to be non-NULL.
> > >
> > > Signed-off-by: Uwe Kleine-K?nig <[email protected]>
> >
> > Acked-by: Richard Purdie <[email protected]>
> The problem was introduced by c835ee7f4154992e6cf0674d7ee136f5d36247a4
> (that is in 2.6.29-rc1). Is this relevant for stable?

Yes.

What is the git commit id of the fix in Linus's tree?

thanks,

greg k-h

2010-11-23 08:56:46

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [stable] [PATCH] backlight: grab ops_lock before testing bd->ops

Hi Greg,

On Mon, Nov 22, 2010 at 09:53:32AM -0800, Greg KH wrote:
> On Mon, Nov 22, 2010 at 11:05:32AM +0100, Uwe Kleine-K?nig wrote:
> > Hello,
> >
> > On Mon, Nov 22, 2010 at 09:59:07AM +0000, Richard Purdie wrote:
> > > On Mon, 2010-11-22 at 10:43 +0100, Uwe Kleine-K?nig wrote:
> > > > According to the comment describing ops_lock in the definition of
> > > > struct backlight_device and when comparing with other functions in
> > > > backlight.c the mutex must be hold when checking ops to be non-NULL.
> > > >
> > > > Signed-off-by: Uwe Kleine-K?nig <[email protected]>
> > >
> > > Acked-by: Richard Purdie <[email protected]>
> > The problem was introduced by c835ee7f4154992e6cf0674d7ee136f5d36247a4
> > (that is in 2.6.29-rc1). Is this relevant for stable?
>
> Yes.
>
> What is the git commit id of the fix in Linus's tree?
I'll let you know when it hits his tree.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |