Skip to content

Commit

Permalink
net: sgi: ioc3-eth: Fix return value check in ioc3eth_probe()
Browse files Browse the repository at this point in the history
In the function devm_platform_ioremap_resource(), if get resource
failed, the return value is ERR_PTR() not NULL. Thus it must be
replaced by IS_ERR(), or else it may result in crashes if a critical
error path is encountered.

Fixes: 0ce5ebd ("mfd: ioc3: Add driver for SGI IOC3 chip")
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Tang Bin authored and David S. Miller committed May 22, 2020
1 parent 41b4bd9 commit a765421
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/net/ethernet/sgi/ioc3-eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -848,14 +848,14 @@ static int ioc3eth_probe(struct platform_device *pdev)
ip = netdev_priv(dev);
ip->dma_dev = pdev->dev.parent;
ip->regs = devm_platform_ioremap_resource(pdev, 0);
if (!ip->regs) {
err = -ENOMEM;
if (IS_ERR(ip->regs)) {
err = PTR_ERR(ip->regs);
goto out_free;
}

ip->ssram = devm_platform_ioremap_resource(pdev, 1);
if (!ip->ssram) {
err = -ENOMEM;
if (IS_ERR(ip->ssram)) {
err = PTR_ERR(ip->ssram);
goto out_free;
}

Expand Down

0 comments on commit a765421

Please sign in to comment.