Skip to content

Commit

Permalink
net: sgi: ioc3-eth: check return value after calling platform_get_res…
Browse files Browse the repository at this point in the history
…ource()

[ Upstream commit db8f7be ]

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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Yang Yingliang authored and gregkh committed Jul 19, 2021
1 parent 42b8412 commit 3b5c55d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/net/ethernet/sgi/ioc3-eth.c
Expand Up @@ -835,6 +835,10 @@ static int ioc3eth_probe(struct platform_device *pdev)
int err;

regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!regs) {
dev_err(&pdev->dev, "Invalid resource\n");
return -EINVAL;
}
/* get mac addr from one wire prom */
if (ioc3eth_get_mac_addr(regs, mac_addr))
return -EPROBE_DEFER; /* not available yet */
Expand Down

0 comments on commit 3b5c55d

Please sign in to comment.