From: Giedrius Statkevičius Date: Sat, 16 Apr 2016 00:27:12 +0000 (+0300) Subject: asus-laptop: correct error handling in asus_read_brightness() X-Git-Tag: v4.7-rc1~30^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=198b618ab118c7d856278a985de1ed0eff77c02f;p=thirdparty%2Fkernel%2Flinux.git asus-laptop: correct error handling in asus_read_brightness() It is possible that acpi_evaluate_integer might fail and value would not be set to any value so correct this defect by returning 0 in case of an error. This is also the correct thing to return because the backlight subsystem will print the old value of brightness in this case. Signed-off-by: Giedrius Statkevičius Signed-off-by: Darren Hart --- diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c index f2b5d0a8adf03..a4cd78691ac93 100644 --- a/drivers/platform/x86/asus-laptop.c +++ b/drivers/platform/x86/asus-laptop.c @@ -775,8 +775,10 @@ static int asus_read_brightness(struct backlight_device *bd) rv = acpi_evaluate_integer(asus->handle, METHOD_BRIGHTNESS_GET, NULL, &value); - if (ACPI_FAILURE(rv)) + if (ACPI_FAILURE(rv)) { pr_warn("Error reading brightness\n"); + return 0; + } return value; }