From: Thorsten Blum <blum@kernel.org>
To: "Mattia Dongili" <malattia@linux.it>,
"Hans de Goede" <hansg@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Matthew Garrett" <mjg@redhat.com>
Cc: Thorsten Blum <blum@kernel.org>, platform-driver-x86@vger.kernel.org
Subject: [PATCH] platform/x86: sony-laptop: Preserve defaults for empty brightness tables
Date: Fri, 20 Nov 2026 14:45:26 +0100 [thread overview]
Message-ID: <20261120134525.823067-2-blum@kernel.org> (raw)
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,
reply other threads:[~2026-11-20 13:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261120134525.823067-2-blum@kernel.org \
--to=blum@kernel.org \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=malattia@linux.it \
--cc=mjg@redhat.com \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.