* [PATCH] drm/panel: summit: Reject out-of-range max brightness values
@ 2026-11-27 13:12 Thorsten Blum
0 siblings, 0 replies; only message in thread
From: Thorsten Blum @ 2026-11-27 13:12 UTC (permalink / raw)
To: Sasha Finkelstein, Janne Grunau, Neil Armstrong, Jessica Zhang,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Dmitry Baryshkov, Neal Gompa, Nick Chan
Cc: Thorsten Blum, dri-devel, asahi
device_property_read_u32() reads the "max-brightness" property directly
into the signed int max_brightness field. Therefore, values above
INT_MAX are interpreted as negative.
Read the property into a temporary u32 and validate it before assigning
it to the signed max_brightness field.
Values above INT_MAX now cause probe to fail with -EINVAL instead of
registering a backlight with a negative maximum brightness.
Fixes: 40115947b59f ("drm: panel: Add a panel driver for the Summit display")
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
Found by code inspection and compile-tested only.
drivers/gpu/drm/panel/panel-summit.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/panel/panel-summit.c b/drivers/gpu/drm/panel/panel-summit.c
index 84435be52424..2d6fb9e08ddb 100644
--- a/drivers/gpu/drm/panel/panel-summit.c
+++ b/drivers/gpu/drm/panel/panel-summit.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
#include <linux/backlight.h>
+#include <linux/limits.h>
#include <linux/property.h>
#include <drm/drm_device.h>
#include <drm/drm_mipi_dsi.h>
@@ -67,6 +68,7 @@ static int summit_probe(struct mipi_dsi_device *dsi)
struct backlight_properties props = { 0 };
struct device *dev = &dsi->dev;
struct summit_data *s_data;
+ u32 max_brightness;
int ret;
s_data = devm_drm_panel_alloc(dev, struct summit_data, panel,
@@ -78,9 +80,14 @@ static int summit_probe(struct mipi_dsi_device *dsi)
mipi_dsi_set_drvdata(dsi, s_data);
s_data->dsi = dsi;
- ret = device_property_read_u32(dev, "max-brightness", &props.max_brightness);
+ ret = device_property_read_u32(dev, "max-brightness", &max_brightness);
if (ret)
return ret;
+
+ if (max_brightness > INT_MAX)
+ return dev_err_probe(dev, -EINVAL, "Invalid maximum brightness: %u\n",
+ max_brightness);
+ props.max_brightness = max_brightness;
props.type = BACKLIGHT_RAW;
s_data->bl = devm_backlight_device_register(dev, dev_name(dev),
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-27 13:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 13:12 [PATCH] drm/panel: summit: Reject out-of-range max brightness values Thorsten Blum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox