gpiolib: Put fwnode reference on failure
PATCH v2 1/1 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 49416483a953 ("gpio: shared: allow sharing a reset-gpios pin between reset-gpio and gpiolib")
Signed-off-by Michail Tatas <[email protected]>
---
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(-)
drivers/gpio/gpiolib-shared.c +6 -3
@@ -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",
Signature · 1 line
2.43.0
Bartosz Golaszewski
AppliedQuoted 5 lines · Michail Tatas
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,
Signature · 1 line
Bartosz Golaszewski <[email protected]>