]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
usb: oxu210hp-hcd: Fix memory leak in oxu_create
authorZhang Qilong <zhangqilong3@huawei.com>
Mon, 23 Nov 2020 14:58:09 +0000 (22:58 +0800)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 20 Jan 2021 13:26:02 +0000 (14:26 +0100)
BugLink: https://bugs.launchpad.net/bugs/1910822
[ Upstream commit e5548b05631ec3e6bfdaef1cad28c799545b791b ]

usb_create_hcd will alloc memory for hcd, and we should
call usb_put_hcd to free it when adding fails to prevent
memory leak.

Fixes: b92a78e582b1a ("usb host: Oxford OXU210HP HCD driver")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
Link: https://lore.kernel.org/r/20201123145809.1456541-1-zhangqilong3@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
drivers/usb/host/oxu210hp-hcd.c

index e67242e437edceb643e4f421b7b8d05d3587ae73..65985247fc00f2d3b695d59e496507d5c4d1485b 100644 (file)
@@ -4149,8 +4149,10 @@ static struct usb_hcd *oxu_create(struct platform_device *pdev,
        oxu->is_otg = otg;
 
        ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
-       if (ret < 0)
+       if (ret < 0) {
+               usb_put_hcd(hcd);
                return ERR_PTR(ret);
+       }
 
        device_wakeup_enable(hcd->self.controller);
        return hcd;