]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
usb: dwc2: check return value after calling platform_get_resource()
authorYang Yingliang <yangyingliang@huawei.com>
Tue, 31 Aug 2021 08:42:36 +0000 (16:42 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Sep 2021 08:32:56 +0000 (10:32 +0200)
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>
drivers/usb/dwc2/hcd.c

index 2a7828971d0564743e7caa933ad485c8eeb5b299..a215ec9e172e69747e5d7c099def5a363b172431 100644 (file)
@@ -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);