diff options
author | Yang Yingliang <yangyingliang@huawei.com> | 2021-08-31 11:42:36 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-09-14 11:32:56 +0300 |
commit | 856e6e8e0f9300befa87dde09edb578555c99a82 (patch) | |
tree | 162056664d5bfd4df98f64e27d96c2b07301fa63 /drivers/usb | |
parent | b69ec50b3e55c4b2a85c8bc46763eaf330605847 (diff) | |
download | linux-856e6e8e0f9300befa87dde09edb578555c99a82.tar.xz |
usb: dwc2: check return value after calling platform_get_resource()
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>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/dwc2/hcd.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 2a7828971d05..a215ec9e172e 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -5191,6 +5191,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); |