Skip to contentSkip to conversation

usb: typec: tcpm: qcom: fix connector fwnode_handle leak in qcom_pmic_typec_port_probe()

PATCH In review Selby Mashiki 3 participants 3 messages Oct 25

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

PATCH 1/1 usb: typec: tcpm: qcom: fix connector fwnode_handle leak in qcom_pmic_typec_port_probe()

In qcom_pmic_typec_port_probe(), device_get_named_child_node(dev, "connector") acquires a reference to the connector fwnode_handle to pass to_of_node(connector) to devm_of_regulator_get_optional(), but never releases the reference.

Call fwnode_handle_put(connector) immediately after devm_of_regulator_get_optional() to fix the leak.

Fixes 506927b6bf29 ("usb: typec: tcpm: qcom: prefer VBUS supply from the connector node")
---
 drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c +1 -0
index bf985efe1..b89495315 100644
@@ -728,6 +728,7 @@ int qcom_pmic_typec_port_probe(struct platform_device *pdev,
 	pmic_typec_port->vdd_vbus = devm_of_regulator_get_optional(dev,
 								   to_of_node(connector),
 								   "vbus");
+	fwnode_handle_put(connector);
 	if (pmic_typec_port->vdd_vbus == ERR_PTR(-ENODEV))
 		pmic_typec_port->vdd_vbus = devm_regulator_get(dev, "vdd-vbus");
 	if (IS_ERR(pmic_typec_port->vdd_vbus))
Signature · 1 line
2.56.0
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 10 lines

In qcom_pmic_typec_port_probe(), device_get_named_child_node(dev, "connector") acquires a reference to the connector fwnode_handle to pass to_of_node(connector) to devm_of_regulator_get_optional(), but never releases the reference.

Call fwnode_handle_put(connector) immediately after devm_of_regulator_get_optional() to fix the leak.

Fixes 506927b6bf29 ("usb: typec: tcpm: qcom: prefer VBUS supply from the connector node")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
In reply to Selby Mashiki
Quoted 5 lines · Selby Mashiki

In qcom_pmic_typec_port_probe(), device_get_named_child_node(dev, "connector") acquires a reference to the connector fwnode_handle to pass to_of_node(connector) to devm_of_regulator_get_optional(), but never releases the reference.

Quoted 9 lines

Call fwnode_handle_put(connector) immediately after devm_of_regulator_get_optional() to fix the leak.

Fixes 506927b6bf29 ("usb: typec: tcpm: qcom: prefer VBUS supply from the connector node")
---
  drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c | 1 +
  1 file changed, 1 insertion(+)

Hello Selby,

check out

https://lore.kernel.org/linux-arm-msm/[email protected]/

This is one of the patches from the gen1 Type-C enablement series and it seems to be almost same as yours, if it looks good to you, feel free to drop A-b/R-b.

Thanks
David

Quoted 12 lines
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c +1 -0
index bf985efe1..b89495315 100644
@@ -728,6 +728,7 @@ int qcom_pmic_typec_port_probe(struct platform_device *pdev,
  	pmic_typec_port->vdd_vbus = devm_of_regulator_get_optional(dev,
  								   to_of_node(connector),
  								   "vbus");
+	fwnode_handle_put(connector);
  	if (pmic_typec_port->vdd_vbus == ERR_PTR(-ENODEV))
  		pmic_typec_port->vdd_vbus = devm_regulator_get(dev, "vdd-vbus");
  	if (IS_ERR(pmic_typec_port->vdd_vbus))