]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
net: moxa: Use devm_platform_get_and_ioremap_resource()
authorYang Yingliang <yangyingliang@huawei.com>
Mon, 7 Jun 2021 15:02:59 +0000 (23:02 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 7 Jun 2021 21:08:30 +0000 (14:08 -0700)
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>
drivers/net/ethernet/moxa/moxart_ether.c

index b85733942053f6b9ef927fa79ef4219a461c91a2..5249b64f4fc549a0fdf30df5b7aa9d523ea76f36 100644 (file)
@@ -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);