Linux Framebuffer Layer development
 help / color / mirror / Atom feed
* [PATCH] backlight: aw99706: Clamp negative max brightness values
@ 2026-11-27  2:14 Thorsten Blum
  2026-11-27  4:50 ` Junjie Cao
  0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2026-11-27  2:14 UTC (permalink / raw)
  To: Junjie Cao, Lee Jones, Daniel Thompson, Jingoo Han, Helge Deller,
	Pengyu Luo
  Cc: Thorsten Blum, Junjie Cao, dri-devel, linux-fbdev

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)

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-27  4:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27  2:14 [PATCH] backlight: aw99706: Clamp negative max brightness values Thorsten Blum
2026-11-27  4:50 ` Junjie Cao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox