Skip to contentSkip to conversation

pinctrl: microchip-sgpio: Put fwnode in error case during ->probe()

PATCH In review Andy Shevchenko 3 participants 3 messages Jun 6, 2021 – Jun 18, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pinctrl: microchip-sgpio: Put fwnode in error case during ->probe()

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 <[email protected]>
---
 drivers/pinctrl/pinctrl-microchip-sgpio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pinctrl/pinctrl-microchip-sgpio.c +3 -1
index c12fa57ebd12..165cb7a59715 100644
@@ -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) {
Signature · 1 line
2.31.1
#1 lore raw

Sun, Jun 06, 2021 at 10:19:40PM +0300, Andy Shevchenko kirjoitti:

Quoted 2 lines

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?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
In reply to Andy Shevchenko
Quoted 6 lines · Andy Shevchenko

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 <[email protected]>

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

Yours,
Linus Walleij