Commit b4a087e9 authored by Yang Yingliang's avatar Yang Yingliang Committed by Wenyu Huang
Browse files

usb: dwc2: check return value after calling platform_get_resource()

stable inclusion
from stable-v4.19.315
commit a7182993dd8e09f96839ddc3ac54f9b37370d282
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I9R4OY
CVE: CVE-2021-47409

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v4.19.315&id=a7182993dd8e09f96839ddc3ac54f9b37370d282



--------------------------------

[ Upstream commit 856e6e8e ]

It will cause null-ptr-deref if platform_get_resource() returns NULL,
we need check the return value.

Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20210831084236.1359677-1-yangyingliang@huawei.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarWenyu Huang <huangwenyu5@huawei.com>
parent d2901c3f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -5233,6 +5233,10 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg)
	hcd->has_tt = 1;

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (!res) {
		retval = -EINVAL;
		goto error1;
	}
	hcd->rsrc_start = res->start;
	hcd->rsrc_len = resource_size(res);