linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpiolib: devres: release GPIOs in devm_gpiod_put_array()
@ 2025-07-15 16:00 André Draszik
  2025-07-15 16:39 ` André Draszik
  2025-07-16  9:09 ` Bartosz Golaszewski
  0 siblings, 2 replies; 4+ messages in thread
From: André Draszik @ 2025-07-15 16:00 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Greg Kroah-Hartman,
	Andy Shevchenko
  Cc: Bartosz Golaszewski, Tudor Ambarus, Peter Griffin, Will McVicker,
	kernel-team, linux-gpio, linux-kernel, André Draszik

devm_gpiod_put_array() is meant to undo the effects of
devm_gpiod_get_array() - in particular, it should release the GPIOs
contained in the array acquired with the latter. It is meant to be the
resource-managed version of gpiod_put_array(), and it should behave
similar to the non-array version devm_gpiod_put().

Since commit d1d52c6622a6 ("gpiolib: devres: Finish the conversion to
use devm_add_action()") it doesn't do that anymore, it just removes the
devres action and frees associated memory, but it doesn't actually
release the GPIOs.

Fix by switching from devm_remove_action() to devm_release_action(),
which will in addition invoke the action to release the GPIOs.

Fixes: d1d52c6622a6 ("gpiolib: devres: Finish the conversion to use devm_add_action()")
Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 drivers/gpio/gpiolib-devres.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib-devres.c b/drivers/gpio/gpiolib-devres.c
index 4d5f83b17624eed04039b94ca6d095fea293e5cc..72422c5db3641e5609759e82ac2ab532fab81783 100644
--- a/drivers/gpio/gpiolib-devres.c
+++ b/drivers/gpio/gpiolib-devres.c
@@ -319,7 +319,7 @@ EXPORT_SYMBOL_GPL(devm_gpiod_unhinge);
  */
 void devm_gpiod_put_array(struct device *dev, struct gpio_descs *descs)
 {
-	devm_remove_action(dev, devm_gpiod_release_array, descs);
+	devm_release_action(dev, devm_gpiod_release_array, descs);
 }
 EXPORT_SYMBOL_GPL(devm_gpiod_put_array);
 

---
base-commit: 58ba80c4740212c29a1cf9b48f588e60a7612209
change-id: 20250715-gpiolib-devres-put-array-fix-d6b365dad018

Best regards,
-- 
André Draszik <andre.draszik@linaro.org>


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

* Re: [PATCH] gpiolib: devres: release GPIOs in devm_gpiod_put_array()
  2025-07-15 16:00 [PATCH] gpiolib: devres: release GPIOs in devm_gpiod_put_array() André Draszik
@ 2025-07-15 16:39 ` André Draszik
  2025-07-16  9:09 ` Bartosz Golaszewski
  1 sibling, 0 replies; 4+ messages in thread
From: André Draszik @ 2025-07-15 16:39 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Greg Kroah-Hartman,
	Andy Shevchenko
  Cc: Bartosz Golaszewski, Tudor Ambarus, Peter Griffin, Will McVicker,
	kernel-team, linux-gpio, linux-kernel

On Tue, 2025-07-15 at 17:00 +0100, André Draszik wrote:
> devm_gpiod_put_array() is meant to undo the effects of
> devm_gpiod_get_array() - in particular, it should release the GPIOs
> contained in the array acquired with the latter. It is meant to be the
> resource-managed version of gpiod_put_array(), and it should behave
> similar to the non-array version devm_gpiod_put().
> 
> Since commit d1d52c6622a6 ("gpiolib: devres: Finish the conversion to
> use devm_add_action()") it doesn't do that anymore, it just removes the
> devres action and frees associated memory, but it doesn't actually
> release the GPIOs.
> 
> Fix by switching from devm_remove_action() to devm_release_action(),
> which will in addition invoke the action to release the GPIOs.
> 
> Fixes: d1d52c6622a6 ("gpiolib: devres: Finish the conversion to use devm_add_action()")

The culprit only exists in 6.16-rc for now, and it shouldn't be
backported to older kernels, hence I didn't add CC: stable, hoping
the patch can make it into the 6.16 release

Please let me know if that is unlikely and I shall send a v2 with
Cc: stable instead.

Cheers,
Andre'

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

* Re: [PATCH] gpiolib: devres: release GPIOs in devm_gpiod_put_array()
  2025-07-15 16:00 [PATCH] gpiolib: devres: release GPIOs in devm_gpiod_put_array() André Draszik
  2025-07-15 16:39 ` André Draszik
@ 2025-07-16  9:09 ` Bartosz Golaszewski
  2025-07-16  9:30   ` Andy Shevchenko
  1 sibling, 1 reply; 4+ messages in thread
From: Bartosz Golaszewski @ 2025-07-16  9:09 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Greg Kroah-Hartman,
	Andy Shevchenko, André Draszik
  Cc: Bartosz Golaszewski, Tudor Ambarus, Peter Griffin, Will McVicker,
	kernel-team, linux-gpio, linux-kernel

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


On Tue, 15 Jul 2025 17:00:20 +0100, André Draszik wrote:
> devm_gpiod_put_array() is meant to undo the effects of
> devm_gpiod_get_array() - in particular, it should release the GPIOs
> contained in the array acquired with the latter. It is meant to be the
> resource-managed version of gpiod_put_array(), and it should behave
> similar to the non-array version devm_gpiod_put().
> 
> Since commit d1d52c6622a6 ("gpiolib: devres: Finish the conversion to
> use devm_add_action()") it doesn't do that anymore, it just removes the
> devres action and frees associated memory, but it doesn't actually
> release the GPIOs.
> 
> [...]

Thanks for catching it, I queued it for v6.16-rc7.

[1/1] gpiolib: devres: release GPIOs in devm_gpiod_put_array()
      https://git.kernel.org/brgl/linux/c/ff20798820e08af0fe757c756914b4aa51993ccb

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

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

* Re: [PATCH] gpiolib: devres: release GPIOs in devm_gpiod_put_array()
  2025-07-16  9:09 ` Bartosz Golaszewski
@ 2025-07-16  9:30   ` Andy Shevchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2025-07-16  9:30 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Linus Walleij, Greg Kroah-Hartman, André Draszik,
	Bartosz Golaszewski, Tudor Ambarus, Peter Griffin, Will McVicker,
	kernel-team, linux-gpio, linux-kernel

On Wed, Jul 16, 2025 at 11:09:31AM +0200, Bartosz Golaszewski wrote:
> On Tue, 15 Jul 2025 17:00:20 +0100, André Draszik wrote:
> > devm_gpiod_put_array() is meant to undo the effects of
> > devm_gpiod_get_array() - in particular, it should release the GPIOs
> > contained in the array acquired with the latter. It is meant to be the
> > resource-managed version of gpiod_put_array(), and it should behave
> > similar to the non-array version devm_gpiod_put().
> > 
> > Since commit d1d52c6622a6 ("gpiolib: devres: Finish the conversion to
> > use devm_add_action()") it doesn't do that anymore, it just removes the
> > devres action and frees associated memory, but it doesn't actually
> > release the GPIOs.

[...]

> Thanks for catching it, I queued it for v6.16-rc7.

Yeah, I used the release function in parameter, but not changed the call.
Thanks for a good catch!

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2025-07-16  9:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-15 16:00 [PATCH] gpiolib: devres: release GPIOs in devm_gpiod_put_array() André Draszik
2025-07-15 16:39 ` André Draszik
2025-07-16  9:09 ` Bartosz Golaszewski
2025-07-16  9:30   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).