]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
usb: typec: ucsi: Put fwnode in any case during ->probe()
authorAndy Shevchenko <andy.shevchenko@gmail.com>
Tue, 4 May 2021 22:23:37 +0000 (01:23 +0300)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 18 Jun 2021 09:07:32 +0000 (11:07 +0200)
BugLink: https://bugs.launchpad.net/bugs/1931292
commit b9a0866a5bdf6a4643a52872ada6be6184c6f4f2 upstream.

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: c1b0bc2dabfa ("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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/usb/typec/ucsi/ucsi.c

index 5cdf030f086fb1e433283f3b8a12a285b670ddf0..89055a05aa41d65cc31d8e415e0819bd55aafdae 100644 (file)
@@ -995,6 +995,7 @@ static const struct typec_operations ucsi_ops = {
        .pr_set = ucsi_pr_swap
 };
 
+/* Caller must call fwnode_handle_put() after use */
 static struct fwnode_handle *ucsi_find_fwnode(struct ucsi_connector *con)
 {
        struct fwnode_handle *fwnode;
@@ -1028,7 +1029,7 @@ static int ucsi_register_port(struct ucsi *ucsi, int index)
        command |= UCSI_CONNECTOR_NUMBER(con->num);
        ret = ucsi_send_command(ucsi, command, &con->cap, sizeof(con->cap));
        if (ret < 0)
-               goto out;
+               goto out_unlock;
 
        if (con->cap.op_mode & UCSI_CONCAP_OPMODE_DRP)
                cap->data = TYPEC_PORT_DRD;
@@ -1124,6 +1125,8 @@ static int ucsi_register_port(struct ucsi *ucsi, int index)
        trace_ucsi_register_port(con->num, &con->status);
 
 out:
+       fwnode_handle_put(cap->fwnode);
+out_unlock:
        mutex_unlock(&con->lock);
        return ret;
 }