提交 fcc028c1 编写于 作者: K Krzysztof Kozlowski 提交者: 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: NKrzysztof Kozlowski <k.kozlowski.k@gmail.com>
Cc: <stable@vger.kernel.org>
Fixes: 46aa27df ("net: axienet: Use devm_* calls")
Reviewed-by: NSören Brinkmann <soren.brinkmann@xilinx.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册