Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a072896a authored by Zhang Qilong's avatar Zhang Qilong Committed by Greg Kroah-Hartman
Browse files

usb: oxu210hp-hcd: Fix memory leak in oxu_create



[ 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: b92a78e5 ("usb host: Oxford OXU210HP HCD driver")
Reported-by: default avatarHulk Robot <hulkci@huawei.com>
Signed-off-by: default avatarZhang Qilong <zhangqilong3@huawei.com>
Link: https://lore.kernel.org/r/20201123145809.1456541-1-zhangqilong3@huawei.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 4659119b
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -3734,8 +3734,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;