From: Yang Yingliang Date: Mon, 7 Jun 2021 13:38:37 +0000 (+0800) Subject: net: bcmgenet: check return value after calling platform_get_resource() X-Git-Tag: baikal/mips/sdk5.9~10650^2~302 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=800bafb2b22793cf2dc175121f0626800daa08fa;p=kernel.git net: bcmgenet: 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 Acked-by: Florian Fainelli Signed-off-by: David S. Miller --- diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c index 5335244e4577a..89d16c587bb7d 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmmii.c +++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c @@ -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));