Skip to content

Commit

Permalink
backlight: grab ops_lock before testing bd->ops
Browse files Browse the repository at this point in the history
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 c835ee7 ("backlight: Add suspend/resume
support to the backlight core") in Jan 2009.

Signed-off-by: Uwe Kleine-König <[email protected]>
Acked-by: Richard Purdie <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Uwe Kleine-König authored and torvalds committed Nov 24, 2010
1 parent b38eeaa commit d1d7357
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions drivers/video/backlight/backlight.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit d1d7357

Please sign in to comment.