platform/x86: sony-laptop: Preserve defaults for empty brightness tables
Subsystems (2)
PATCH 1/1 platform/x86: sony-laptop: Preserve defaults for empty brightness tables
If the brightness table returned by the SN06 ACPI method is empty or its first entry is zero, sony_nc_backlight_ng_read_limits() overwrites ->offset and ->maxlvl with min = 255 and max = 0, respectively, which results in an invalid max_brightness of -255.
Return before updating ->offset and ->maxlvl if min > max to preserve the default values (0 and 255) and to avoid a negative max_brightness.
Fixes 62d2f23e8bce ("[PATCH] sony-laptop: limit brightness range to DSDT provided ones")
Signed-off-by Thorsten Blum <[email protected]>
---
Found by code inspection but not reproduced on hardware.
drivers/platform/x86/sony-laptop.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/platform/x86/sony-laptop.c +3 -0
@@ -3076,6 +3076,9 @@ static void sony_nc_backlight_ng_read_limits(int handle,if (buffer[i] < min) min = buffer[i]; } + +if (min > max) +return ; props->offset = min; props->maxlvl = max; dprintk("Brightness levels: min=%d max=%d\n", props->offset,