summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/broadcom/genet/bcmmii.c
diff options
context:
space:
mode:
authorYang Yingliang <yangyingliang@huawei.com>2021-06-07 16:38:37 +0300
committerDavid S. Miller <davem@davemloft.net>2021-06-08 00:07:22 +0300
commit74325bf0104573c6dfce42837139aeef3f34be76 (patch)
tree3c6eae205f4b3b7064e30b0b9475bdc84da8b71a /drivers/net/ethernet/broadcom/genet/bcmmii.c
parent90fdd89f6cf99213073dd9623f98519c767630d6 (diff)
downloadlinux-74325bf0104573c6dfce42837139aeef3f34be76.tar.xz
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 <yangyingliang@huawei.com> Acked-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/broadcom/genet/bcmmii.c')
-rw-r--r--drivers/net/ethernet/broadcom/genet/bcmmii.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c
index 5335244e4577..89d16c587bb7 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));