* [PATCH] platform/loongarch: laptop: Reject negative max brightness values
@ 2026-11-27 15:55 Thorsten Blum
2026-11-27 16:07 ` Thorsten Blum
0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2026-11-27 15:55 UTC (permalink / raw)
To: Huacai Chen, WANG Xuerui, Jianmin Lv, Rafael J. Wysocki
Cc: loongarch, Thorsten Blum
laptop_backlight_register() uses the maximum brightness reported by the
ECLL ACPI method without validating it. A negative result could cause
the driver to register a backlight with an invalid brightness range.
Return -EINVAL for negative values before powering on and registering
the backlight.
Fixes: 6246ed09111f ("LoongArch: Add ACPI-based generic laptop driver")
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
Found by code inspection and compile-tested only.
drivers/platform/loongarch/loongson-laptop.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/platform/loongarch/loongson-laptop.c b/drivers/platform/loongarch/loongson-laptop.c
index 4ec56621db24..d582eec765ef 100644
--- a/drivers/platform/loongarch/loongson-laptop.c
+++ b/drivers/platform/loongarch/loongson-laptop.c
@@ -415,6 +415,11 @@ static int laptop_backlight_register(void)
if (!acpi_evalf(hotkey_handle, &status, "ECLL", "d"))
return -EIO;
+ if (status < 0) {
+ pr_err("Invalid maximum brightness: %d\n", status);
+ return -EINVAL;
+ }
+
ret = ec_backlight_set_power(true);
if (ret)
return ret;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] platform/loongarch: laptop: Reject negative max brightness values
2026-11-27 15:55 [PATCH] platform/loongarch: laptop: Reject negative max brightness values Thorsten Blum
@ 2026-11-27 16:07 ` Thorsten Blum
0 siblings, 0 replies; 2+ messages in thread
From: Thorsten Blum @ 2026-11-27 16:07 UTC (permalink / raw)
To: Huacai Chen, WANG Xuerui, Jianmin Lv, Rafael J. Wysocki
Cc: loongarch, linux-kernel
+Cc linux-kernel@vger.kernel.org
On Fri, Nov 27, 2026 at 04:55:08PM +0100, Thorsten Blum wrote:
> laptop_backlight_register() uses the maximum brightness reported by the
> ECLL ACPI method without validating it. A negative result could cause
> the driver to register a backlight with an invalid brightness range.
>
> Return -EINVAL for negative values before powering on and registering
> the backlight.
>
> Fixes: 6246ed09111f ("LoongArch: Add ACPI-based generic laptop driver")
> Signed-off-by: Thorsten Blum <blum@kernel.org>
> ---
> Found by code inspection and compile-tested only.
>
> drivers/platform/loongarch/loongson-laptop.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/platform/loongarch/loongson-laptop.c b/drivers/platform/loongarch/loongson-laptop.c
> index 4ec56621db24..d582eec765ef 100644
> --- a/drivers/platform/loongarch/loongson-laptop.c
> +++ b/drivers/platform/loongarch/loongson-laptop.c
> @@ -415,6 +415,11 @@ static int laptop_backlight_register(void)
> if (!acpi_evalf(hotkey_handle, &status, "ECLL", "d"))
> return -EIO;
>
> + if (status < 0) {
> + pr_err("Invalid maximum brightness: %d\n", status);
> + return -EINVAL;
> + }
> +
> ret = ec_backlight_set_power(true);
> if (ret)
> return ret;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-27 16:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 15:55 [PATCH] platform/loongarch: laptop: Reject negative max brightness values Thorsten Blum
2026-11-27 16:07 ` Thorsten Blum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox