gpio: adnp: fix flow control regression caused by scoped_guard()
PATCH 1/1 gpio: adnp: fix flow control regression caused by scoped_guard()
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.
--- drivers/gpio/gpio-adnp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpio/gpio-adnp.c +3 -1
@@ -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 ;
Signature · 1 line
2.47.3
Quoted 9 lines · Bartosz Golaszewski
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 insidescoped_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 <[email protected]>Signed-off-by Bartosz Golaszewski <[email protected]>
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
Bartosz Golaszewski
AppliedQuoted 6 lines · Bartosz Golaszewski
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 insidescoped_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,
Signature · 1 line
Bartosz Golaszewski <[email protected]>