All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thorsten Blum <blum@kernel.org>
To: Junjie Cao <junjie.cao@linux.dev>, Lee Jones <lee@kernel.org>,
	Daniel Thompson <danielt@kernel.org>,
	Jingoo Han <jingoohan1@gmail.com>, Helge Deller <deller@gmx.de>,
	Pengyu Luo <mitltlatltl@gmail.com>
Cc: Thorsten Blum <blum@kernel.org>,
	Junjie Cao <caojunjie650@gmail.com>,
	dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org
Subject: [PATCH] backlight: aw99706: Clamp negative max brightness values
Date: Fri, 27 Nov 2026 03:14:23 +0100	[thread overview]
Message-ID: <20261127021423.656745-2-blum@kernel.org> (raw)

device_property_read_u32() reads the "max-brightness" property directly
into the signed int max_brightness field. Values larger than INT_MAX are
interpreted as negative and pass the upper-bound check.

Also clamp negative values to AW99706_MAX_BRT_LVL to prevent this.

Fixes: 147b38a5ad06 ("backlight: aw99706: Add support for Awinic AW99706 backlight")
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
 drivers/video/backlight/aw99706.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/video/backlight/aw99706.c b/drivers/video/backlight/aw99706.c
index 43f82c83f91a..c8168a36284d 100644
--- a/drivers/video/backlight/aw99706.c
+++ b/drivers/video/backlight/aw99706.c
@@ -272,7 +272,8 @@ static void aw99706_dt_parse(struct aw99706_device *aw,
 	device_property_read_u32(aw->dev, "max-brightness",
 				 &bl_props->max_brightness);
 
-	if (bl_props->max_brightness > AW99706_MAX_BRT_LVL)
+	if (bl_props->max_brightness < 0 ||
+	    bl_props->max_brightness > AW99706_MAX_BRT_LVL)
 		bl_props->max_brightness = AW99706_MAX_BRT_LVL;
 
 	if (bl_props->brightness > bl_props->max_brightness)

             reply	other threads:[~2026-11-27  2:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27  2:14 Thorsten Blum [this message]
2026-11-27  4:50 ` [PATCH] backlight: aw99706: Clamp negative max brightness values Junjie Cao

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=20261127021423.656745-2-blum@kernel.org \
    --to=blum@kernel.org \
    --cc=caojunjie650@gmail.com \
    --cc=danielt@kernel.org \
    --cc=deller@gmx.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jingoohan1@gmail.com \
    --cc=junjie.cao@linux.dev \
    --cc=lee@kernel.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=mitltlatltl@gmail.com \
    /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.