From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796232928; b=AbMSN53lc1UfpB4/I0+2bBMiS9Z7ER4tBac4pM6S9KaVHa15DnDphGoAwJb9ymPTL4tb HmxLjztKlQgVJJtfYGLJbO8etaujCEN7E05kK2/2TnIkt5H+hpFLj6UtVKTvvHhqJ1IfA 6u+1y9BCKLf6wtutn4xeSIT85TxB9aMTfyzfet3qcK4T43ySTY71nqCQk8e1dNwFDGpq+ rz60D9R9o3avMHMLxnYGjHwkYBdx1nyNXhpOkjgSw2DoyvIVqBVf+DPAF70sFaygcfhf7 OUODleLPM+iFNIIgTXnjRayh5R1hvDjbByp5SQMhg79/2h8yjQ8epbkhIOOzjBurlnw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796232928; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=bx8SDLpvr11uefyizzLLwGV535ScxJN95pxbJB0bFCQ=; b=EyojRnd7HvCAkZIKyoRFA11hjiMJ1jW3nvPH1K2sS24doSxAgSuaF0dvC7zcvZ5hV6sL fdcpUA30pxScOrk34SwMITcDnbXJ5oDQhoXVKv4duk9iXo0UeYaEjiU2HrEEG2hcqcAaw lzH4XYPzRQL52r7tLSl2EO+YAvpUrL0ylF4PAercP4DW8soaWbwAMY/J7Je6hTAyUz6Sy e4kIGAIzN5+kvera30JLbYPSxn8Qum0nFJd9hctPXhQguIwmQ5+8srzRHAI62E5XpQd+8 nF5jacBguAl3p0/8T0Kg6D9+kZKNye95U/QTriSehgGlyDdqItHSWMNgId4308whheg== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VvR+A6HK; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 32FEF606A325; Wed, 2 Dec 2026 17:35:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VvR+A6HK Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796232928; b=oBOsw4ZyYi/9xUMXj030GEfG4mTNOpQ558Zg2+KGTobj4Zh33ciuoxjH/Nkdsyt9uqG+ bMHzydFpxntv3jkQWgUtOvG6JMZ5N4pXbKLLtArPO7jWDw8ySXZrQ4MJBiv294Md2fszc A10mrET1gJfjIuLZWOWwILfLCcC/gc6pc0fD4zHgvLKrB6VT7NecVeaESYcHstZWDNOUQ SUYE7FY5frt3G0s8LdiM2y7kqdXbHvNgOU2R+/1DEPqXf9bDFiRLnvBlt4H6l44V//5Q5 6hIv5T9TVKWSavxH5LCpVmn0Q5idEU1Pvwweblx910SwD6CIuFp34JVDxRUYxt1BeHQ== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796232928; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=bx8SDLpvr11uefyizzLLwGV535ScxJN95pxbJB0bFCQ=; b=Se5RDNJM/HV8lwpZSLXJ3riVp8NVzgIYeTiWs9d6GgfEF6dVLAnyc8Tub5mpMWaLOOHi 4ylnbP4XRB3T9yzufOCa31HT8JSoFAEW1l2nH1ToFnqwpZuYGtx5R5IA1l1vJbGJj0nvT 2dUz8EBs2wck79/VVhRPKils/d0bzeMVApo5y2CYL5Y9jiYpYYVc82CG6KhlszXKGZXCY 5GJJy+f4UKtKB/BrDbZs0NU+xZbAXAbuDS+hFV4TfAGG43VRmG6onKuyI2QdY6byVEaXc UBDeT/QFRSKf5DPAJKy5FKlPqIcdkZnKBmqDCIynXyeGtjJqK5/YXmIGRAumtS9dZjA== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id D0EC51F00925; Wed, 2 Dec 2026 17:35:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796232928; bh=bx8SDLpvr11uefyizzLLwGV535ScxJN95pxbJB0bFCQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=VvR+A6HK4xq4Qi77rvRYs+J6bpVaqJZTGCG7ZsWZHn3ErNlHdXppWEI/McVoD2Hcn 19RBtQpF6ADy0YiopoeyK8mnCRZ3sBEoMLdd5TBqwwU+QYZgF+DlXxTI5qC515r6rx sgZBwOn37Wzm+W0X2dc1Aip6LnNvcy15r9I2hkqcW0RCXciJBUc9ryu7GmS3QqnIsD 1oveKWTB3W1jmWjTk9kl6e7xa8BadQsUX4SkWl1LCOEO0HUtVde0T9IBosRZQ9hJDW KACLBtM1/nakGATTWaORo79TMGRayLKazVxwRdHR8i9FOT5rnFxTzj0bmIkYsdSZST EvQ5jUKA6teAw== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 5E1334F567; Wed, 2 Dec 2026 17:35:16 +0000 (UTC) From: Matt Moeller via B4 Relay Date: Wed, 02 Dec 2026 11:34:55 -0600 Subject: [PATCH 2/2] leds: rgb: leds-group-multicolor: Fix overflow with high max_brightness X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Message-Id: <20261202-for-upstream-v1-2-709b6da8706b@kinze.com> References: <20261202-for-upstream-v1-0-709b6da8706b@kinze.com> In-Reply-To: <20261202-for-upstream-v1-0-709b6da8706b@kinze.com> To: Lee Jones , Pavel Machek , Griffin Kroah-Hartman , Daniel Mack , Jean-Jacques Hiblot Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Matt Moeller X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796232915; l=2026; i=matthew.moeller@kinze.com; s=20261202; h=from:subject:message-id; bh=SJXehIpsqV+iQImVStely5zJkNszRiMYk2I6KSEgdu4=; b=sCQjulfJt89AINsFIcBqcKRKmORmNZDylq76Zmvu/2bf7jj69MYiAbFW/9Sqo4A+9pMGdSYSo dgdsbQkUgiYDhsEf9xdJa+jXHUpzZWUvFT++IMMeLIGmQDaa9ocF+GK X-Developer-Key: i=matthew.moeller@kinze.com; a=ed25519; pk=JySOK4I4nq7IdjCTDrJ2bfdeioLfzUkXqkJX1bcv9Hc= X-Endpoint-Received: by B4 Relay for matthew.moeller@kinze.com/20261202 with auth_id=1722 X-Original-From: Matt Moeller Reply-To: matthew.moeller@kinze.com Content-Transfer-Encoding: 7bit From: Matt Moeller leds_gmc_set() multiplies brightness, intensity and the monochromatic LED's max_brightness in unsigned int, and DIV_ROUND_CLOSEST() then adds half the divisor. With 12-bit LEDs (max_brightness 4095, e.g. the IS31FL3293) the result passes UINT_MAX as soon as brightness * intensity passes about 2^20, and the LEDs get wrapped values: a group at 4095 with intensities 1605 1284 0 sets red 68 and green 3 instead of 1605 and 1284, and a group brightness of 256 at full intensity sets 0. Do the calculation in 64 bits. The problem was found and this fix written with help from Claude (Anthropic), and tested on hardware. Fixes: 37d0849ed392 ("leds: rgb: Add a multicolor LED driver to group monochromatic LEDs") Cc: stable@vger.kernel.org Signed-off-by: Matt Moeller --- drivers/leds/rgb/leds-group-multicolor.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/leds/rgb/leds-group-multicolor.c b/drivers/leds/rgb/leds-group-multicolor.c index a707d51c6a4b..797538f73115 100644 --- a/drivers/leds/rgb/leds-group-multicolor.c +++ b/drivers/leds/rgb/leds-group-multicolor.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -41,8 +42,10 @@ static int leds_gmc_set(struct led_classdev *cdev, enum led_brightness brightnes * Scale the brightness according to relative intensity of the * color AND the max brightness of the monochromatic LED. */ - mono_brightness = DIV_ROUND_CLOSEST(brightness * intensity * mono_max_brightness, - group_max_brightness * group_max_brightness); + mono_brightness = DIV64_U64_ROUND_CLOSEST((u64)brightness * intensity * + mono_max_brightness, + (u64)group_max_brightness * + group_max_brightness); led_set_brightness(mono, mono_brightness); } -- 2.53.0