Re: [PATCH] pinctrl: nomadik: Add error handling for find_nmk_gpio_from_pin
From: Linus Walleij
Date: Thu Feb 27 2025 - 15:24:18 EST
Hi Wentao,
thanks for your patch!
On Thu, Feb 20, 2025 at 9:51 AM Wentao Liang <vulab@xxxxxxxxxxx> wrote:
> When find_nmk_gpio_from_pin fails to find a valid GPIO chip
> for the given pin, the bit variable remains uninitialized. This
> uninitialized value is then passed to __nmk_gpio_set_mode,
> leading to undefined behavior and undesired address access.
>
> To fix this, add error handling to check the return value of
> find_nmk_gpio_from_pin. Log an error message indicating an
> invalid pin offset and return -EINVAL immediately If the function
> fails.
>
> Fixes: 75d270fda64d ("gpio: nomadik: request dynamic ID allocation")
> Cc: stable@xxxxxxxxxxxxxxx # 6.9+
Unnecessary to tag for stable. It is not causing regressions.
Skip this and apply for nonurgent fixes.
> Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
Reviewed-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
Yours,
Linus Walleij