net: axienet: move use of resource after validity check
authorRobert Hancock <hancock@sedsystems.ca>
Tue, 11 Jun 2019 16:56:02 +0000 (10:56 -0600)
committerDavid S. Miller <davem@davemloft.net>
Fri, 14 Jun 2019 05:41:24 +0000 (22:41 -0700)
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/xilinx/xilinx_axienet_main.c

index da420c88166216a1758a9f7b2f75de0dcec4cf08..561e28a5df04df8b60ecdac58fc09aef307f0d67 100644 (file)
@@ -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;