Skip to content

Commit b9a0866

Browse files
andy-shevgregkh
authored andcommitted
usb: typec: ucsi: Put fwnode in any 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: c1b0bc2 ("usb: typec: Add support for UCSI interface") Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20210504222337.3151726-1-andy.shevchenko@gmail.com Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 2e2b8d1 commit b9a0866

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/usb/typec/ucsi/ucsi.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,7 @@ static const struct typec_operations ucsi_ops = {
999999
.pr_set = ucsi_pr_swap
10001000
};
10011001

1002+
/* Caller must call fwnode_handle_put() after use */
10021003
static struct fwnode_handle *ucsi_find_fwnode(struct ucsi_connector *con)
10031004
{
10041005
struct fwnode_handle *fwnode;
@@ -1033,7 +1034,7 @@ static int ucsi_register_port(struct ucsi *ucsi, int index)
10331034
command |= UCSI_CONNECTOR_NUMBER(con->num);
10341035
ret = ucsi_send_command(ucsi, command, &con->cap, sizeof(con->cap));
10351036
if (ret < 0)
1036-
goto out;
1037+
goto out_unlock;
10371038

10381039
if (con->cap.op_mode & UCSI_CONCAP_OPMODE_DRP)
10391040
cap->data = TYPEC_PORT_DRD;
@@ -1151,6 +1152,8 @@ static int ucsi_register_port(struct ucsi *ucsi, int index)
11511152
trace_ucsi_register_port(con->num, &con->status);
11521153

11531154
out:
1155+
fwnode_handle_put(cap->fwnode);
1156+
out_unlock:
11541157
mutex_unlock(&con->lock);
11551158
return ret;
11561159
}

0 commit comments

Comments
 (0)