Patch "usb: typec: tcpci: fix of node refcount leak in tcpci_register_port()" has been added to the 6.0-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    usb: typec: tcpci: fix of node refcount leak in tcpci_register_port()

to the 6.0-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     usb-typec-tcpci-fix-of-node-refcount-leak-in-tcpci_r.patch
and it can be found in the queue-6.0 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 4be3276e64032485bd3594dafe6b279b6d2a842c
Author: Yang Yingliang <yangyingliang@xxxxxxxxxx>
Date:   Mon Nov 21 14:24:16 2022 +0800

    usb: typec: tcpci: fix of node refcount leak in tcpci_register_port()
    
    [ Upstream commit 0384e87e3fec735e47f1c133c796f32ef7a72a9b ]
    
    I got the following report while doing device(mt6370-tcpc) load
    test with CONFIG_OF_UNITTEST and CONFIG_OF_DYNAMIC enabled:
    
      OF: ERROR: memory leak, expected refcount 1 instead of 2,
      of_node_get()/of_node_put() unbalanced - destroy cset entry:
      attach overlay node /i2c/pmic@34/tcpc/connector
    
    The 'fwnode' set in tcpci_parse_config() which is called
    in tcpci_register_port(), its node refcount is increased
    in device_get_named_child_node(). It needs be put while
    exiting, so call fwnode_handle_put() in the error path of
    tcpci_register_port() and in tcpci_unregister_port() to
    avoid leak.
    
    Fixes: 5e85a04c8c0d ("usb: typec: add fwnode to tcpc")
    Signed-off-by: Yang Yingliang <yangyingliang@xxxxxxxxxx>
    Acked-by: Heikki Krogerus <heikki.krogerus@xxxxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20221121062416.1026192-1-yangyingliang@xxxxxxxxxx
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
index 812784702d53..592bd4c85482 100644
--- a/drivers/usb/typec/tcpm/tcpci.c
+++ b/drivers/usb/typec/tcpm/tcpci.c
@@ -816,8 +816,10 @@ struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data)
 		return ERR_PTR(err);
 
 	tcpci->port = tcpm_register_port(tcpci->dev, &tcpci->tcpc);
-	if (IS_ERR(tcpci->port))
+	if (IS_ERR(tcpci->port)) {
+		fwnode_handle_put(tcpci->tcpc.fwnode);
 		return ERR_CAST(tcpci->port);
+	}
 
 	return tcpci;
 }
@@ -826,6 +828,7 @@ EXPORT_SYMBOL_GPL(tcpci_register_port);
 void tcpci_unregister_port(struct tcpci *tcpci)
 {
 	tcpm_unregister_port(tcpci->port);
+	fwnode_handle_put(tcpci->tcpc.fwnode);
 }
 EXPORT_SYMBOL_GPL(tcpci_unregister_port);
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux