X86 platform drivers
 help / color / mirror / Atom feed
* [PATCH] platform/x86: sony-laptop: Preserve defaults for empty brightness tables
@ 2026-11-20 13:45 Thorsten Blum
  0 siblings, 0 replies; only message in thread
From: Thorsten Blum @ 2026-11-20 13:45 UTC (permalink / raw)
  To: Mattia Dongili, Hans de Goede, Ilpo Järvinen,
	Matthew Garrett
  Cc: Thorsten Blum, platform-driver-x86

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 <blum@kernel.org>
---
Found by code inspection but not reproduced on hardware.

 drivers/platform/x86/sony-laptop.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 0bf4d3054e37..5d2f91f140f2 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -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,

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-20 13:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 13:45 [PATCH] platform/x86: sony-laptop: Preserve defaults for empty brightness tables Thorsten Blum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox