[PATCH] pinctrl: nomadik: Add error handling for find_nmk_gpio_from_pin

Linus Walleij linus.walleij at linaro.org
Thu Feb 27 12:23:47 PST 2025


Hi Wentao,

thanks for your patch!

On Thu, Feb 20, 2025 at 9:51 AM Wentao Liang <vulab at iscas.ac.cn> 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 at vger.kernel.org # 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 at iscas.ac.cn>

Reviewed-by: Linus Walleij <linus.walleij at linaro.org>

Yours,
Linus Walleij



More information about the linux-arm-kernel mailing list