Skip to content

Commit

Permalink
net: moxa: Use devm_platform_get_and_ioremap_resource()
Browse files Browse the repository at this point in the history
Use devm_platform_get_and_ioremap_resource() to simplify
code and avoid a null-ptr-deref by checking 'res' in it.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Yang Yingliang authored and David S. Miller committed Jun 7, 2021
1 parent 7f553ff commit 35cba15
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/net/ethernet/moxa/moxart_ether.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,13 +481,12 @@ static int moxart_mac_probe(struct platform_device *pdev)
priv->ndev = ndev;
priv->pdev = pdev;

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
ndev->base_addr = res->start;
priv->base = devm_ioremap_resource(p_dev, res);
priv->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(priv->base)) {
ret = PTR_ERR(priv->base);
goto init_fail;
}
ndev->base_addr = res->start;

spin_lock_init(&priv->txlock);

Expand Down

0 comments on commit 35cba15

Please sign in to comment.