Re: [PATCH] gpio: adnp: fix flow control regression caused by scoped_guard()

From: Linus Walleij

Date: Mon May 25 2026 - 09:27:41 EST


On Fri, May 22, 2026 at 9:35 AM Bartosz Golaszewski
<bartosz.golaszewski@xxxxxxxxxxxxxxxx> wrote:

> scoped_guard() is implemented as a for loop. Using it to protect code
> using the continue statement changes the flow as we now only break out
> of the hidden loop inside scoped_guard(), not the original for loop. Use
> a regular code block instead.
>
> Fixes: c7fe19ed3973 ("gpio: adnp: use lock guards for the I2C lock")
> Reported-by: David Lechner <dlechner@xxxxxxxxxxxx>
> Closes: https://lore.kernel.org/all/cde2abb2-4cc8-4fc9-b34a-0c5d2b95779f@xxxxxxxxxxxx/
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>

Reviewed-by: Linus Walleij <linusw@xxxxxxxxxx>

This class of bugs would be nice to identify with tools, both AI
and Cocinelle.

Julia, do you know if we can make a coccicheck script that warn
about scoped_guard() { continue; }?

Yours,
Linus Walleij