Commit fcc028c1 authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by David S. Miller

net: axienet: Fix devm_ioremap_resource return value check

Value returned by devm_ioremap_resource() was checked for non-NULL but
devm_ioremap_resource() returns IOMEM_ERR_PTR, not NULL. In case of
error this could lead to dereference of ERR_PTR.
Signed-off-by: default avatarKrzysztof Kozlowski <k.kozlowski.k@gmail.com>
Cc: <stable@vger.kernel.org>
Fixes: 46aa27df ("net: axienet: Use devm_* calls")
Reviewed-by: default avatarSören Brinkmann <soren.brinkmann@xilinx.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fc5778ca
...@@ -1530,9 +1530,9 @@ static int axienet_probe(struct platform_device *pdev) ...@@ -1530,9 +1530,9 @@ static int axienet_probe(struct platform_device *pdev)
/* Map device registers */ /* Map device registers */
ethres = platform_get_resource(pdev, IORESOURCE_MEM, 0); ethres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
lp->regs = devm_ioremap_resource(&pdev->dev, ethres); lp->regs = devm_ioremap_resource(&pdev->dev, ethres);
if (!lp->regs) { if (IS_ERR(lp->regs)) {
dev_err(&pdev->dev, "could not map Axi Ethernet regs.\n"); dev_err(&pdev->dev, "could not map Axi Ethernet regs.\n");
ret = -ENOMEM; ret = PTR_ERR(lp->regs);
goto free_netdev; goto free_netdev;
} }
...@@ -1599,9 +1599,9 @@ static int axienet_probe(struct platform_device *pdev) ...@@ -1599,9 +1599,9 @@ static int axienet_probe(struct platform_device *pdev)
goto free_netdev; goto free_netdev;
} }
lp->dma_regs = devm_ioremap_resource(&pdev->dev, &dmares); lp->dma_regs = devm_ioremap_resource(&pdev->dev, &dmares);
if (!lp->dma_regs) { if (IS_ERR(lp->dma_regs)) {
dev_err(&pdev->dev, "could not map DMA regs\n"); dev_err(&pdev->dev, "could not map DMA regs\n");
ret = -ENOMEM; ret = PTR_ERR(lp->dma_regs);
goto free_netdev; goto free_netdev;
} }
lp->rx_irq = irq_of_parse_and_map(np, 1); lp->rx_irq = irq_of_parse_and_map(np, 1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment