Skip to content

Commit c689426

Browse files
javiercarrascocruzgregkh
authored andcommitted
usb: typec: ucsi: glink: fix child node release in probe function
The device_for_each_child_node() macro requires explicit calls to fwnode_handle_put() in all early exits of the loop if the child node is not required outside. Otherwise, the child node's refcount is not decremented and the resource is not released. The current implementation of pmic_glink_ucsi_probe() makes use of the device_for_each_child_node(), but does not release the child node on early returns. Add the missing calls to fwnode_handle_put(). Cc: [email protected] Fixes: c6165ed ("usb: ucsi: glink: use the connector orientation GPIO to provide switch events") Signed-off-by: Javier Carrasco <[email protected]> Reviewed-by: Dmitry Baryshkov <[email protected]> Reviewed-by: Heikki Krogerus <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent de644a4 commit c689426

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/usb/typec/ucsi/ucsi_glink.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ static int pmic_glink_ucsi_probe(struct auxiliary_device *adev,
372372
ret = fwnode_property_read_u32(fwnode, "reg", &port);
373373
if (ret < 0) {
374374
dev_err(dev, "missing reg property of %pOFn\n", fwnode);
375+
fwnode_handle_put(fwnode);
375376
return ret;
376377
}
377378

@@ -386,9 +387,11 @@ static int pmic_glink_ucsi_probe(struct auxiliary_device *adev,
386387
if (!desc)
387388
continue;
388389

389-
if (IS_ERR(desc))
390+
if (IS_ERR(desc)) {
391+
fwnode_handle_put(fwnode);
390392
return dev_err_probe(dev, PTR_ERR(desc),
391393
"unable to acquire orientation gpio\n");
394+
}
392395
ucsi->port_orientation[port] = desc;
393396
}
394397

0 commit comments

Comments
 (0)