This is an automated email from the ASF dual-hosted git repository.

jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 75b3c8e2a46 drivers: leds: Fix LP503X bank mode LED bounds
75b3c8e2a46 is described below

commit 75b3c8e2a463cbe28a2449eb37c77e71701b2aa1
Author: aineoae86-sys <[email protected]>
AuthorDate: Mon Jul 6 03:04:37 2026 +0800

    drivers: leds: Fix LP503X bank mode LED bounds
    
    PWMIOC_ENABLE_LED_BANK_MODE uses the provided LED number to index the 
LP503X led_mode array. Reject values outside the RGB LED range before writing 
that array.
    
    Generated-by: OpenAI Codex
    Signed-off-by: aineoae86-sys <[email protected]>
---
 drivers/leds/lp503x.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/leds/lp503x.c b/drivers/leds/lp503x.c
index 384bf9ed7ad..5e33e762be4 100644
--- a/drivers/leds/lp503x.c
+++ b/drivers/leds/lp503x.c
@@ -829,6 +829,12 @@ static int lp503x_ioctl(struct file *filep, int cmd,
         break;
 
       case PWMIOC_ENABLE_LED_BANK_MODE: /* led(0..11), mode required */
+        if (lp503x_ioctl_args->lednum > MAX_RGB_LEDS)
+          {
+            ret = -EINVAL;
+            break;
+          }
+
         ledinfo("INFO: setting LED %d mode to %" PRIx32 "\n",
                 lp503x_ioctl_args->lednum,
                 lp503x_ioctl_args->param);

Reply via email to