Skip to contentSkip to conversation

platform/chrome: cros_ec_typec: Put fwnode in error case during ->probe()

PATCH Superseded Andy Shevchenko 2 participants 2 messages Jun 14, 2021

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/chrome: cros_ec_typec: 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 fdc6b21e2444 ("platform/chrome: Add Type C connector class driver")
Cc Prashant Malani <[email protected]>
---
 drivers/platform/chrome/cros_ec_typec.c | 1 +
 1 file changed, 1 insertion(+)
drivers/platform/chrome/cros_ec_typec.c +1 -0
index 27c068c4c38d..fb03c22fa34d 100644
@@ -375,6 +375,7 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
 	return 0;
 
 unregister_ports:
+	fwnode_handle_put(fwnode);
 	cros_unregister_ports(typec);
 	return ret;
 }
Signature · 1 line
2.32.0
Reviewed-by on v1 1/1
#1 lore raw

Hi Andy,

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 fdc6b21e2444 ("platform/chrome: Add Type C connector class driver")
Cc Prashant Malani <[email protected]>

Minor nit, but regardless of that:

drivers/platform/chrome/cros_ec_typec.c static int cros_typec_init_ports(struct cros_typec_data *typec) · line 378

Quoted 13 lines
---
 drivers/platform/chrome/cros_ec_typec.c | 1 +
 1 file changed, 1 insertion(+)
drivers/platform/chrome/cros_ec_typec.c +1 -0
index 27c068c4c38d..fb03c22fa34d 100644
@@ -375,6 +375,7 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
 	return 0;
 
 unregister_ports:
+	fwnode_handle_put(fwnode);

It reads better to have this at the location where the goto's are called, but there are several of them. Instead, can you add a 1-line comment explaining that the reference is left over? It isn't clear even by going a few calls down the stack of device_for_each_child_node().

Best regards,

-Prashant