USB: core: fix device node leak
authorJohan Hovold <johan@kernel.org>
Tue, 6 Jun 2017 15:58:58 +0000 (17:58 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 12 Jul 2017 13:01:03 +0000 (15:01 +0200)
commit e271b2c909a22a2c13b2d5f77f2ce0091b74540c upstream.

Make sure to release any OF device-node reference taken when creating
the USB device.

Note that we currently do not hold a reference to the root hub
device-tree node (i.e. the parent controller node).

Fixes: 69bec7259853 ("USB: core: let USB device know device node")
Acked-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/core/usb.c

index 5921514610179f04232e11da85746344ff3ee3e0..eaf1c3b06f028257c2b39bdcbaa4b73d82e2c169 100644 (file)
@@ -279,6 +279,8 @@ static void usb_release_dev(struct device *dev)
 
        usb_destroy_configuration(udev);
        usb_release_bos_descriptor(udev);
+       if (udev->parent)
+               of_node_put(dev->of_node);
        usb_put_hcd(hcd);
        kfree(udev->product);
        kfree(udev->manufacturer);