Commit b3b4dc88 authored by Ben Dooks's avatar Ben Dooks Committed by Linus Torvalds

lcd: fix oops if driver only interested in .set_power

The LCD driver core calls LCD drivers when either the blanking state or
the display mode has changed, but does not make any check to see if the
called driver has a .set_mode method.

This means if a driver only has a .set_power method then the system will
OOPS on changing mode (and with the console semaphore held so you cannot
easily see the problem).

Fix the problem by ensuring that either callback is valid before use.
Signed-off-by: default avatarBen Dooks <ben-linux@fluff.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent c267fd77
...@@ -42,10 +42,13 @@ static int fb_notifier_callback(struct notifier_block *self, ...@@ -42,10 +42,13 @@ static int fb_notifier_callback(struct notifier_block *self,
mutex_lock(&ld->ops_lock); mutex_lock(&ld->ops_lock);
if (!ld->ops->check_fb || ld->ops->check_fb(ld, evdata->info)) { if (!ld->ops->check_fb || ld->ops->check_fb(ld, evdata->info)) {
if (event == FB_EVENT_BLANK) if (event == FB_EVENT_BLANK) {
ld->ops->set_power(ld, *(int *)evdata->data); if (ld->ops->set_power)
else ld->ops->set_power(ld, *(int *)evdata->data);
ld->ops->set_mode(ld, evdata->data); } else {
if (ld->ops->set_mode)
ld->ops->set_mode(ld, evdata->data);
}
} }
mutex_unlock(&ld->ops_lock); mutex_unlock(&ld->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