Skip to contentSkip to conversation

platform/x86: sony-laptop: Preserve defaults for empty brightness tables

PATCH New Thorsten Blum 1 participant 1 message Nov 20

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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")

---
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
index 0bf4d3054e37..5d2f91f140f2 100644
@@ -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,