* [PATCH AUTOSEL 4.14 7/8] usb: dwc2: check return value after calling platform_get_resource()
[not found] <20210928055727.173078-1-sashal@kernel.org>
@ 2021-09-28 5:57 ` Sasha Levin
0 siblings, 0 replies; only message in thread
From: Sasha Levin @ 2021-09-28 5:57 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Yang Yingliang, Greg Kroah-Hartman, Sasha Levin, hminas, linux-usb
From: Yang Yingliang <yangyingliang@huawei.com>
[ Upstream commit 856e6e8e0f9300befa87dde09edb578555c99a82 ]
It will cause null-ptr-deref if platform_get_resource() returns NULL,
we need check the return value.
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20210831084236.1359677-1-yangyingliang@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/usb/dwc2/hcd.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index ef7f3b013fcb..ba7528916da4 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -5229,6 +5229,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);
--
2.33.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-09-28 6:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20210928055727.173078-1-sashal@kernel.org>
2021-09-28 5:57 ` [PATCH AUTOSEL 4.14 7/8] usb: dwc2: check return value after calling platform_get_resource() Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).