Thread (3 messages) 3 messages, 3 authors, 2025-02-27

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

From: Linus Walleij <hidden>
Date: 2025-02-27 20:24:00
Also in: linux-gpio, lkml, stable

Hi Wentao,

thanks for your patch!

On Thu, Feb 20, 2025 at 9:51 AM Wentao Liang [off-list ref] 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@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 <redacted>
Reviewed-by: Linus Walleij <redacted>

Yours,
Linus Walleij
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help