gpiolib: Put fwnode reference on failure

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: 49416483a9 ("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>
Link: https://patch.msgid.link/an4Asr4tx3D2QvLD@michalis-linux
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
This commit is contained in:
Michail Tatas 2026-08-13 20:36:50 +03:00 committed by Bartosz Golaszewski
parent 45c13f3f9e
commit 16b10f64c6

View File

@ -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",