Linux GPIO subsystem development
 help / color / mirror / Atom feed
* [PATCH v2] gpiolib: Put fwnode reference on failure
@ 2026-08-13 17:36 Michail Tatas
  2026-08-26 16:00 ` Bartosz Golaszewski
  0 siblings, 1 reply; 2+ messages in thread
From: Michail Tatas @ 2026-08-13 17:36 UTC (permalink / raw)
  To: linusw, brgl; +Cc: linux-gpio, linux-kernel

We get a reference to the fwnode handle which we pass to
gpio_shared_make_ref. In case it fails we do not put the reference.
Fix by putting the reference in the failure case

Fixes: 49416483a953 ("gpio: shared: allow sharing a reset-gpios pin between reset-gpio and gpiolib")
Cc: stable@vger.kernel.org
Signed-off-by: Michail Tatas <michail.tatas@gmail.com>
---

Changes in v2:
 - Added Cc and Fixes Tags based on the review from Bart

Revisions:
 - v1: https://lore.kernel.org/all/anUA90ZcyYp9ka3E@michalis-linux/

 drivers/gpio/gpiolib-shared.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpiolib-shared.c b/drivers/gpio/gpiolib-shared.c
index 495bd3d0ddf0..5f9623e40b0f 100644
--- a/drivers/gpio/gpiolib-shared.c
+++ b/drivers/gpio/gpiolib-shared.c
@@ -261,10 +261,13 @@ static int gpio_shared_of_traverse(struct device_node *curr)
 				con_id[con_id_len - suffix_len] = '\0';
 			}
 
-			ref = gpio_shared_make_ref(fwnode_handle_get(of_fwnode_handle(curr)),
-						   con_id, args.args[1]);
-			if (!ref)
+			struct fwnode_handle *curr_fwnode =
+				fwnode_handle_get(of_fwnode_handle(curr));
+			ref = gpio_shared_make_ref(curr_fwnode, con_id, args.args[1]);
+			if (!ref) {
+				fwnode_handle_put(curr_fwnode);
 				return -ENOMEM;
+			}
 
 			if (!list_empty(&entry->refs))
 				pr_debug("GPIO %u at %s is shared by multiple firmware nodes\n",
-- 
2.43.0


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

* Re: [PATCH v2] gpiolib: Put fwnode reference on failure
  2026-08-13 17:36 [PATCH v2] gpiolib: Put fwnode reference on failure Michail Tatas
@ 2026-08-26 16:00 ` Bartosz Golaszewski
  0 siblings, 0 replies; 2+ messages in thread
From: Bartosz Golaszewski @ 2026-08-26 16:00 UTC (permalink / raw)
  To: linusw, brgl, Michail Tatas; +Cc: Bartosz Golaszewski, linux-gpio, linux-kernel


On Thu, 13 Aug 2026 20:36:50 +0300, Michail Tatas wrote:
> We get a reference to the fwnode handle which we pass to
> gpio_shared_make_ref. In case it fails we do not put the reference.
> Fix by putting the reference in the failure case
> 
> 

Applied, thanks!

[1/1] gpiolib: Put fwnode reference on failure
      https://git.kernel.org/brgl/c/16b10f64c63f78220c3b4035f1ed6cd3bdcb0b02

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

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

end of thread, other threads:[~2026-08-26 16:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-13 17:36 [PATCH v2] gpiolib: Put fwnode reference on failure Michail Tatas
2026-08-26 16:00 ` Bartosz Golaszewski

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