gpio: aggregator: Fix off by one in gpiochip_fwd_desc_add()
authorDan Carpenter <dan.carpenter@linaro.org>
Wed, 13 Aug 2025 05:38:27 +0000 (08:38 +0300)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Wed, 13 Aug 2025 07:22:59 +0000 (09:22 +0200)
commit148547000cfc1ba8cec02857268333d08724b9cc
treea38f6d033c0a0ad0a197e6559e1e32d951107074
parent38f7b4a6a0510bc9b578b2bbf31e434d84b3244b
gpio: aggregator: Fix off by one in gpiochip_fwd_desc_add()

The "> chip->ngpio" comparison here needs to be ">= chip->ngpio",
otherwise it leads to an out of bounds access.  The fwd->valid_mask
bitmap only has chip->ngpio bits and the fwd->descs[] array has that
same number of elements.  These values are set in
devm_gpiochip_fwd_alloc().

Fixes: c44ce91b8ada ("gpio: aggregator: refactor the code to add GPIO desc in the forwarder")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/aJwk0yBSCccGCjX3@stanley.mountain
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
drivers/gpio/gpio-aggregator.c