Skip to content

Commit

Permalink
usb: oxu210hp-hcd: Fix memory leak in oxu_create
Browse files Browse the repository at this point in the history
[ Upstream commit e5548b0 ]

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: b92a78e ("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>
  • Loading branch information
Zhang Qilong authored and gregkh committed Dec 30, 2020
1 parent 2addd72 commit 989d527
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/usb/host/oxu210hp-hcd.c
Expand Up @@ -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;
Expand Down

0 comments on commit 989d527

Please sign in to comment.