Skip to content

Commit 249e0ab

Browse files
Yang Yinglianggregkh
authored andcommitted
net: moxa: Use devm_platform_get_and_ioremap_resource()
commit 35cba15 upstream. Use devm_platform_get_and_ioremap_resource() to simplify code and avoid a null-ptr-deref by checking 'res' in it. [yyl: since devm_platform_get_and_ioremap_resource() is introduced in linux-5.7, so just check the return value after calling platform_get_resource()] Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 359311b commit 249e0ab

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/net/ethernet/moxa/moxart_ether.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,10 @@ static int moxart_mac_probe(struct platform_device *pdev)
481481
priv->pdev = pdev;
482482

483483
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
484+
if (!res) {
485+
ret = -EINVAL;
486+
goto init_fail;
487+
}
484488
ndev->base_addr = res->start;
485489
priv->base = devm_ioremap_resource(p_dev, res);
486490
if (IS_ERR(priv->base)) {

0 commit comments

Comments
 (0)