]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
USB: host: isp116x: check return value after calling platform_get_resource()
authorZhen Ni <nizhen@uniontech.com>
Wed, 2 Mar 2022 03:37:16 +0000 (11:37 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Jun 2022 16:32:42 +0000 (18:32 +0200)
[ Upstream commit 134a3408c2d3f7e23eb0e4556e0a2d9f36c2614e ]

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

Signed-off-by: Zhen Ni <nizhen@uniontech.com>
Link: https://lore.kernel.org/r/20220302033716.31272-1-nizhen@uniontech.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/usb/host/isp116x-hcd.c

index 3055d9abfec302c5c931025b5bfa5b2c0d1afc7b..3e5c54742befe092daf406658f02709aa6aaac28 100644 (file)
@@ -1541,10 +1541,12 @@ static int isp116x_remove(struct platform_device *pdev)
 
        iounmap(isp116x->data_reg);
        res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-       release_mem_region(res->start, 2);
+       if (res)
+               release_mem_region(res->start, 2);
        iounmap(isp116x->addr_reg);
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       release_mem_region(res->start, 2);
+       if (res)
+               release_mem_region(res->start, 2);
 
        usb_put_hcd(hcd);
        return 0;