diff mbox

[2/2] fb: avoid possible deadlock caused by fb_set_suspend

Message ID 1295392199-31264-2-git-send-email-herton@mandriva.com.br (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Herton Ronaldo Krzesinski Jan. 18, 2011, 11:09 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 05d09ac..6747e06 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1741,8 +1741,7 @@  void fb_set_suspend(struct fb_info *info, int state)
 {
 	struct fb_event event;
 
-	if (!lock_fb_info(info))
-		return;
+	WARN_ON(info->state == FBINFO_STATE_EXITING);
 	event.info = info;
 	if (state) {
 		fb_notifier_call_chain(FB_EVENT_SUSPEND, &event);
@@ -1751,7 +1750,6 @@  void fb_set_suspend(struct fb_info *info, int state)
 		info->state = FBINFO_STATE_RUNNING;
 		fb_notifier_call_chain(FB_EVENT_RESUME, &event);
 	}
-	unlock_fb_info(info);
 }
 
 /**
diff --git a/drivers/video/fbsysfs.c b/drivers/video/fbsysfs.c
index be361b5..2ba5370 100644
--- a/drivers/video/fbsysfs.c
+++ b/drivers/video/fbsysfs.c
@@ -401,9 +401,12 @@  static ssize_t store_fbstate(struct device *device,
 	if (state && state > 1)
 		return -EINVAL;
 
+	if (!lock_fb_info(fb_info))
+		return -ENODEV;
 	acquire_console_sem();
 	fb_set_suspend(fb_info, (int)state);
 	release_console_sem();
+	unlock_fb_info(fb_info);
 
 	return count;
 }