Commit d1d73578 authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Linus Torvalds

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.

Fixes a problem added by c835ee7f ("backlight: Add suspend/resume
support to the backlight core") in Jan 2009.
Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: default avatarRichard Purdie <rpurdie@linux.intel.com>
Cc: <stable@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent b38eeaae
...@@ -197,12 +197,12 @@ static int backlight_suspend(struct device *dev, pm_message_t state) ...@@ -197,12 +197,12 @@ static int backlight_suspend(struct device *dev, pm_message_t state)
{ {
struct backlight_device *bd = to_backlight_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; bd->props.state |= BL_CORE_SUSPENDED;
backlight_update_status(bd); backlight_update_status(bd);
mutex_unlock(&bd->ops_lock);
} }
mutex_unlock(&bd->ops_lock);
return 0; return 0;
} }
...@@ -211,12 +211,12 @@ static int backlight_resume(struct device *dev) ...@@ -211,12 +211,12 @@ static int backlight_resume(struct device *dev)
{ {
struct backlight_device *bd = to_backlight_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; bd->props.state &= ~BL_CORE_SUSPENDED;
backlight_update_status(bd); backlight_update_status(bd);
mutex_unlock(&bd->ops_lock);
} }
mutex_unlock(&bd->ops_lock);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment