net: ethernet: ixp4xx: Add error handling in ixp4xx_eth_probe()
authorTang Bin <tangbin@cmss.chinamobile.com>
Thu, 23 Apr 2020 02:16:31 +0000 (10:16 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 23 Apr 2020 22:32:45 +0000 (15:32 -0700)
The function ixp4xx_eth_probe() does not perform sufficient error
checking after executing devm_ioremap_resource(), which can result
in crashes if a critical error path is encountered.

Fixes: f458ac479777 ("ARM/net: ixp4xx: Pass ethernet physical base as resource")
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/xscale/ixp4xx_eth.c

index 269596c15133d01008d699baf47ec6a8ecef8a5d..2e52029235104762b0ea4870433c2df7347addd9 100644 (file)
@@ -1387,6 +1387,8 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
                return -ENODEV;
        regs_phys = res->start;
        port->regs = devm_ioremap_resource(dev, res);
+       if (IS_ERR(port->regs))
+               return PTR_ERR(port->regs);
 
        switch (port->id) {
        case IXP4XX_ETH_NPEA: