]>
Commit | Line | Data |
---|---|---|
622952ea GKH |
1 | From d1d73578e053b981c3611e5a211534290d24a5eb Mon Sep 17 00:00:00 2001 |
2 | From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de> | |
3 | Date: Wed, 24 Nov 2010 12:57:14 -0800 | |
4 | Subject: backlight: grab ops_lock before testing bd->ops | |
5 | MIME-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ||
9 | From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de> | |
10 | ||
11 | commit d1d73578e053b981c3611e5a211534290d24a5eb upstream. | |
12 | ||
13 | According to the comment describing ops_lock in the definition of struct | |
14 | backlight_device and when comparing with other functions in backlight.c | |
15 | the mutex must be hold when checking ops to be non-NULL. | |
16 | ||
17 | Fixes a problem added by c835ee7f4154992e6 ("backlight: Add suspend/resume | |
18 | support to the backlight core") in Jan 2009. | |
19 | ||
20 | Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | |
21 | Acked-by: Richard Purdie <rpurdie@linux.intel.com> | |
22 | Signed-off-by: Andrew Morton <akpm@linux-foundation.org> | |
23 | Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> | |
24 | Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> | |
25 | ||
26 | --- | |
27 | drivers/video/backlight/backlight.c | 12 ++++++------ | |
28 | 1 file changed, 6 insertions(+), 6 deletions(-) | |
29 | ||
30 | --- a/drivers/video/backlight/backlight.c | |
31 | +++ b/drivers/video/backlight/backlight.c | |
32 | @@ -196,12 +196,12 @@ static int backlight_suspend(struct devi | |
33 | { | |
34 | struct backlight_device *bd = to_backlight_device(dev); | |
35 | ||
36 | - if (bd->ops->options & BL_CORE_SUSPENDRESUME) { | |
37 | - mutex_lock(&bd->ops_lock); | |
38 | + mutex_lock(&bd->ops_lock); | |
39 | + if (bd->ops && bd->ops->options & BL_CORE_SUSPENDRESUME) { | |
40 | bd->props.state |= BL_CORE_SUSPENDED; | |
41 | backlight_update_status(bd); | |
42 | - mutex_unlock(&bd->ops_lock); | |
43 | } | |
44 | + mutex_unlock(&bd->ops_lock); | |
45 | ||
46 | return 0; | |
47 | } | |
48 | @@ -210,12 +210,12 @@ static int backlight_resume(struct devic | |
49 | { | |
50 | struct backlight_device *bd = to_backlight_device(dev); | |
51 | ||
52 | - if (bd->ops->options & BL_CORE_SUSPENDRESUME) { | |
53 | - mutex_lock(&bd->ops_lock); | |
54 | + mutex_lock(&bd->ops_lock); | |
55 | + if (bd->ops && bd->ops->options & BL_CORE_SUSPENDRESUME) { | |
56 | bd->props.state &= ~BL_CORE_SUSPENDED; | |
57 | backlight_update_status(bd); | |
58 | - mutex_unlock(&bd->ops_lock); | |
59 | } | |
60 | + mutex_unlock(&bd->ops_lock); | |
61 | ||
62 | return 0; | |
63 | } |