Linux on Apple ARM platform development
 help / color / mirror / Atom feed
From: Thorsten Blum <blum@kernel.org>
To: Sasha Finkelstein <k@chaosmail.tech>, Janne Grunau <j@jannau.net>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Jessica Zhang <jesszhan0024@gmail.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Dmitry Baryshkov <lumag@kernel.org>, Neal Gompa <neal@gompa.dev>,
	Nick Chan <towinchenmi@gmail.com>
Cc: Thorsten Blum <blum@kernel.org>,
	dri-devel@lists.freedesktop.org, asahi@lists.linux.dev
Subject: [PATCH] drm/panel: summit: Reject out-of-range max brightness values
Date: Fri, 27 Nov 2026 14:12:59 +0100	[thread overview]
Message-ID: <20261127131258.682952-2-blum@kernel.org> (raw)

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

                 reply	other threads:[~2026-11-27 13:13 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=20261127131258.682952-2-blum@kernel.org \
    --to=blum@kernel.org \
    --cc=airlied@gmail.com \
    --cc=asahi@lists.linux.dev \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=j@jannau.net \
    --cc=jesszhan0024@gmail.com \
    --cc=k@chaosmail.tech \
    --cc=lumag@kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=neal@gompa.dev \
    --cc=neil.armstrong@linaro.org \
    --cc=simona@ffwll.ch \
    --cc=towinchenmi@gmail.com \
    --cc=tzimmermann@suse.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox