diff mbox series

[v1,1/1] pinctrl: microchip-sgpio: Put fwnode in error case during ->probe()

Message ID 20210606191940.29312-1-andy.shevchenko@gmail.com
State Accepted
Commit 76b7f8fae30a9249f820e019f1e62eca992751a2
Headers show
Series [v1,1/1] pinctrl: microchip-sgpio: Put fwnode in error case during ->probe() | expand

Commit Message

Andy Shevchenko June 6, 2021, 7:19 p.m. UTC
device_for_each_child_node() bumps a reference counting of a returned variable.
We have to balance it whenever we return to the caller.

Fixes: 7e5ea974e61c ("pinctrl: pinctrl-microchip-sgpio: Add pinctrl driver for Microsemi Serial GPIO")
Cc: Lars Povlsen <lars.povlsen@microchip.com>
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/pinctrl/pinctrl-microchip-sgpio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

andy@surfacebook.localdomain June 17, 2021, 7:31 a.m. UTC | #1
Sun, Jun 06, 2021 at 10:19:40PM +0300, Andy Shevchenko kirjoitti:
> device_for_each_child_node() bumps a reference counting of a returned variable.

> We have to balance it whenever we return to the caller.


Linus, any comments on this? Can it be applied sooner than later since
it's a fix?

-- 
With Best Regards,
Andy Shevchenko
Linus Walleij June 18, 2021, 9:19 a.m. UTC | #2
On Sun, Jun 6, 2021 at 9:21 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:

> device_for_each_child_node() bumps a reference counting of a returned variable.

> We have to balance it whenever we return to the caller.

>

> Fixes: 7e5ea974e61c ("pinctrl: pinctrl-microchip-sgpio: Add pinctrl driver for Microsemi Serial GPIO")

> Cc: Lars Povlsen <lars.povlsen@microchip.com>

> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>


Patch applied for fixes, I got a bit snowed under because of
patch-spot activity.

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/pinctrl/pinctrl-microchip-sgpio.c b/drivers/pinctrl/pinctrl-microchip-sgpio.c
index c12fa57ebd12..165cb7a59715 100644
--- a/drivers/pinctrl/pinctrl-microchip-sgpio.c
+++ b/drivers/pinctrl/pinctrl-microchip-sgpio.c
@@ -845,8 +845,10 @@  static int microchip_sgpio_probe(struct platform_device *pdev)
 	i = 0;
 	device_for_each_child_node(dev, fwnode) {
 		ret = microchip_sgpio_register_bank(dev, priv, fwnode, i++);
-		if (ret)
+		if (ret) {
+			fwnode_handle_put(fwnode);
 			return ret;
+		}
 	}
 
 	if (priv->in.gpio.ngpio != priv->out.gpio.ngpio) {