[net-next] net: axienet: move use of resource after validity check
diff mbox series

Message ID 1560272162-14856-1-git-send-email-hancock@sedsystems.ca
State Accepted
Delegated to: David Miller
Headers show
Series
  • [net-next] net: axienet: move use of resource after validity check
Related show

Commit Message

Robert Hancock June 11, 2019, 4:56 p.m. UTC
We were accessing the pointer returned from platform_get_resource before
checking if it was valid, causing an oops if it was not. Move this access
after the call to devm_ioremap_resource which does the validity check.

Signed-off-by: Robert Hancock <hancock@sedsystems.ca>
---

This bug was introduced in my recent axienet patch series and so is only
needed on net-next.

 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrew Lunn June 12, 2019, 1:49 p.m. UTC | #1
On Tue, Jun 11, 2019 at 10:56:02AM -0600, Robert Hancock wrote:
> We were accessing the pointer returned from platform_get_resource before
> checking if it was valid, causing an oops if it was not. Move this access
> after the call to devm_ioremap_resource which does the validity check.
> 
> Signed-off-by: Robert Hancock <hancock@sedsystems.ca>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
David Miller June 14, 2019, 5:41 a.m. UTC | #2
From: Robert Hancock <hancock@sedsystems.ca>
Date: Tue, 11 Jun 2019 10:56:02 -0600

> We were accessing the pointer returned from platform_get_resource before
> checking if it was valid, causing an oops if it was not. Move this access
> after the call to devm_ioremap_resource which does the validity check.
> 
> Signed-off-by: Robert Hancock <hancock@sedsystems.ca>

Applied.

Patch
diff mbox series

diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index da420c8..561e28a 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -1679,13 +1679,13 @@  static int axienet_probe(struct platform_device *pdev)
 	lp->tx_bd_num = TX_BD_NUM_DEFAULT;
 	/* Map device registers */
 	ethres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	lp->regs_start = ethres->start;
 	lp->regs = devm_ioremap_resource(&pdev->dev, ethres);
 	if (IS_ERR(lp->regs)) {
 		dev_err(&pdev->dev, "could not map Axi Ethernet regs.\n");
 		ret = PTR_ERR(lp->regs);
 		goto free_netdev;
 	}
+	lp->regs_start = ethres->start;
 
 	/* Setup checksum offload, but default to off if not specified */
 	lp->features = 0;