mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] gpio: adnp: fix flow control regression caused by scoped_guard()
@ 2026-05-22  7:35 Bartosz Golaszewski
  2026-05-25 13:24 ` Linus Walleij
  2026-05-26  8:34 ` Bartosz Golaszewski
  0 siblings, 2 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2026-05-22  7:35 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski
  Cc: linux-kernel, linux-gpio, Bartosz Golaszewski, David Lechner

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@baylibre.com>
Closes: https://lore.kernel.org/all/cde2abb2-4cc8-4fc9-b34a-0c5d2b95779f@baylibre.com/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/gpio/gpio-adnp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-adnp.c b/drivers/gpio/gpio-adnp.c
index 27a80d1143a1..350feea2afa3 100644
--- a/drivers/gpio/gpio-adnp.c
+++ b/drivers/gpio/gpio-adnp.c
@@ -237,7 +237,9 @@ static irqreturn_t adnp_irq(int irq, void *data)
 		unsigned long pending;
 		int err;
 
-		scoped_guard(mutex, &adnp->i2c_lock) {
+		{
+			guard(mutex)(&adnp->i2c_lock);
+
 			err = adnp_read(adnp, GPIO_PLR(adnp) + i, &level);
 			if (err < 0)
 				continue;
-- 
2.47.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gpio: adnp: fix flow control regression caused by scoped_guard()
  2026-05-22  7:35 [PATCH] gpio: adnp: fix flow control regression caused by scoped_guard() Bartosz Golaszewski
@ 2026-05-25 13:24 ` Linus Walleij
  2026-05-26  8:34 ` Bartosz Golaszewski
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2026-05-25 13:24 UTC (permalink / raw)
  To: Bartosz Golaszewski, julia.lawall
  Cc: Bartosz Golaszewski, linux-kernel, linux-gpio, David Lechner

On Fri, May 22, 2026 at 9:35 AM Bartosz Golaszewski
<bartosz.golaszewski@oss.qualcomm.com> 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@baylibre.com>
> Closes: https://lore.kernel.org/all/cde2abb2-4cc8-4fc9-b34a-0c5d2b95779f@baylibre.com/
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

Reviewed-by: Linus Walleij <linusw@kernel.org>

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gpio: adnp: fix flow control regression caused by scoped_guard()
  2026-05-22  7:35 [PATCH] gpio: adnp: fix flow control regression caused by scoped_guard() Bartosz Golaszewski
  2026-05-25 13:24 ` Linus Walleij
@ 2026-05-26  8:34 ` Bartosz Golaszewski
  1 sibling, 0 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2026-05-26  8:34 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Bartosz Golaszewski
  Cc: linux-kernel, linux-gpio, David Lechner


On Fri, 22 May 2026 09:35:27 +0200, Bartosz Golaszewski 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.
> 
> 

Applied, thanks!

[1/1] gpio: adnp: fix flow control regression caused by scoped_guard()
      https://git.kernel.org/brgl/c/7df1b49aadadb0be1baec2a101b3ab3986e40e7f

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-26  8:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-22  7:35 [PATCH] gpio: adnp: fix flow control regression caused by scoped_guard() Bartosz Golaszewski
2026-05-25 13:24 ` Linus Walleij
2026-05-26  8:34 ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®