lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191021000824.531-8-linus.walleij@linaro.org>
Date:   Mon, 21 Oct 2019 02:08:21 +0200
From:   Linus Walleij <linus.walleij@...aro.org>
To:     netdev@...r.kernel.org, "David S . Miller" <davem@...emloft.net>
Cc:     Arnd Bergmann <arnd@...db.de>,
        Linus Walleij <linus.walleij@...aro.org>
Subject: [PATCH 07/10] net: ehernet: ixp4xx: Use devm_alloc_etherdev()

Using the devm_alloc_etherdev() function simplifies the error
path. I also patch the message to use dev_info().

Signed-off-by: Linus Walleij <linus.walleij@...aro.org>
---
 drivers/net/ethernet/xscale/ixp4xx_eth.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index fbe328693de5..df18d8ebb170 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -1378,7 +1378,7 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
 
 	plat = dev_get_platdata(dev);
 
-	if (!(ndev = alloc_etherdev(sizeof(struct port))))
+	if (!(ndev = devm_alloc_etherdev(dev, sizeof(struct port))))
 		return -ENOMEM;
 
 	SET_NETDEV_DEV(ndev, dev);
@@ -1432,8 +1432,7 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
 		regs_phys  = IXP4XX_EthC_BASE_PHYS;
 		break;
 	default:
-		err = -ENODEV;
-		goto err_free;
+		return -ENODEV;
 	}
 
 	ndev->netdev_ops = &ixp4xx_netdev_ops;
@@ -1442,10 +1441,8 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
 
 	netif_napi_add(ndev, &port->napi, eth_poll, NAPI_WEIGHT);
 
-	if (!(port->npe = npe_request(NPE_ID(port->id)))) {
-		err = -EIO;
-		goto err_free;
-	}
+	if (!(port->npe = npe_request(NPE_ID(port->id))))
+		return -EIO;
 
 	port->mem_res = request_mem_region(regs_phys, REGS_SIZE, ndev->name);
 	if (!port->mem_res) {
@@ -1479,8 +1476,8 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
 	if ((err = register_netdev(ndev)))
 		goto err_phy_dis;
 
-	printk(KERN_INFO "%s: MII PHY %i on %s\n", ndev->name, plat->phy,
-	       npe_name(port->npe));
+	dev_info(dev, "%s: MII PHY %i on %s\n", ndev->name, plat->phy,
+		 npe_name(port->npe));
 
 	return 0;
 
@@ -1491,8 +1488,6 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
 	release_resource(port->mem_res);
 err_npe_rel:
 	npe_release(port->npe);
-err_free:
-	free_netdev(ndev);
 	return err;
 }
 
@@ -1508,7 +1503,6 @@ static int ixp4xx_eth_remove(struct platform_device *pdev)
 	npe_port_tab[NPE_ID(port->id)] = NULL;
 	npe_release(port->npe);
 	release_resource(port->mem_res);
-	free_netdev(ndev);
 	return 0;
 }
 
-- 
2.21.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ