From: Michael Hanselmann Date: Mon, 25 Sep 2006 23:25:07 +0000 (-0700) Subject: [PATCH] backlight: fix oops in __mutex_lock_slowpath during head /sys/class/graphics... X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=25981de5b836581364612a4b1fe27db3b5d1f861;p=GitHub%2FLineageOS%2Fandroid_kernel_samsung_universal7580.git [PATCH] backlight: fix oops in __mutex_lock_slowpath during head /sys/class/graphics/fb0/* Seems like not all drivers use the framebuffer_alloc() function and won't have an initialized mutex. But those don't have a backlight, anyway. Signed-off-by: Michael Hanselmann Cc: Olaf Hering Cc: "Antonino A. Daplas" Cc: Daniel R Thompson Cc: Jon Smirl Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/video/fbsysfs.c b/drivers/video/fbsysfs.c index 4f78f234473..c151dcf6878 100644 --- a/drivers/video/fbsysfs.c +++ b/drivers/video/fbsysfs.c @@ -397,6 +397,12 @@ static ssize_t store_bl_curve(struct class_device *class_device, u8 tmp_curve[FB_BACKLIGHT_LEVELS]; unsigned int i; + /* Some drivers don't use framebuffer_alloc(), but those also + * don't have backlights. + */ + if (!fb_info || !fb_info->bl_dev) + return -ENODEV; + if (count != (FB_BACKLIGHT_LEVELS / 8 * 24)) return -EINVAL; @@ -430,6 +436,12 @@ static ssize_t show_bl_curve(struct class_device *class_device, char *buf) ssize_t len = 0; unsigned int i; + /* Some drivers don't use framebuffer_alloc(), but those also + * don't have backlights. + */ + if (!fb_info || !fb_info->bl_dev) + return -ENODEV; + mutex_lock(&fb_info->bl_mutex); for (i = 0; i < FB_BACKLIGHT_LEVELS; i += 8) len += snprintf(&buf[len], PAGE_SIZE,