]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: bcmgenet: check return value after calling platform_get_resource()
authorYang Yingliang <yangyingliang@huawei.com>
Mon, 7 Jun 2021 13:38:37 +0000 (21:38 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 7 Jun 2021 21:07:22 +0000 (14:07 -0700)
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>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/genet/bcmmii.c

index 5335244e4577ad301df65cab4818d35012208ef9..89d16c587bb7dcb9b430fcf51d496b244bdfa410 100644 (file)
@@ -423,6 +423,10 @@ static int bcmgenet_mii_register(struct bcmgenet_priv *priv)
        int id, ret;
 
        pres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (!pres) {
+               dev_err(&pdev->dev, "Invalid resource\n");
+               return -EINVAL;
+       }
        memset(&res, 0, sizeof(res));
        memset(&ppd, 0, sizeof(ppd));