Patch "usb: roles: fix of node refcount leak in usb_role_switch_is_parent()" has been added to the 5.4-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: roles: fix of node refcount leak in usb_role_switch_is_parent()

to the 5.4-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-roles-fix-of-node-refcount-leak-in-usb_role_swit.patch
and it can be found in the queue-5.4 subdirectory.

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



commit c2b0e746439d3071decf85741115129a39bfe279
Author: Yang Yingliang <yangyingliang@xxxxxxxxxx>
Date:   Tue Nov 22 19:12:26 2022 +0800

    usb: roles: fix of node refcount leak in usb_role_switch_is_parent()
    
    [ Upstream commit 1ab30c610630da5391a373cddb8a065bf4c4bc01 ]
    
    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
    
    The 'parent' returned by fwnode_get_parent() with refcount incremented.
    it needs be put after using.
    
    Fixes: 6fadd72943b8 ("usb: roles: get usb-role-switch from parent")
    Reviewed-by: Heikki Krogerus <heikki.krogerus@xxxxxxxxxxxxxxx>
    Signed-off-by: Yang Yingliang <yangyingliang@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20221122111226.251588-1-yangyingliang@xxxxxxxxxx
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c
index 97e3d75b19a3..873d89823f5b 100644
--- a/drivers/usb/roles/class.c
+++ b/drivers/usb/roles/class.c
@@ -108,10 +108,13 @@ usb_role_switch_is_parent(struct fwnode_handle *fwnode)
 	struct fwnode_handle *parent = fwnode_get_parent(fwnode);
 	struct device *dev;
 
-	if (!parent || !fwnode_property_present(parent, "usb-role-switch"))
+	if (!fwnode_property_present(parent, "usb-role-switch")) {
+		fwnode_handle_put(parent);
 		return NULL;
+	}
 
 	dev = class_find_device_by_fwnode(role_class, parent);
+	fwnode_handle_put(parent);
 	return dev ? to_role_switch(dev) : ERR_PTR(-EPROBE_DEFER);
 }
 



[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