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: <20240930202434.296960-7-rosenp@gmail.com>
Date: Mon, 30 Sep 2024 13:24:31 -0700
From: Rosen Penev <rosenp@...il.com>
To: netdev@...r.kernel.org
Cc: andrew@...n.ch,
	davem@...emloft.net,
	edumazet@...gle.com,
	kuba@...nel.org,
	pabeni@...hat.com,
	linux-kernel@...r.kernel.org,
	olek2@...pl,
	shannon.nelson@....com
Subject: [PATCH net-next 6/9] net: lantiq_etop: use devm_err_probe

Also remove pointless gotos that just return as a result of devm
conversions.

Signed-off-by: Rosen Penev <rosenp@...il.com>
---
 drivers/net/ethernet/lantiq_etop.c | 61 ++++++++++--------------------
 1 file changed, 21 insertions(+), 40 deletions(-)

diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
index 9ca8f01585f6..bc97b189785e 100644
--- a/drivers/net/ethernet/lantiq_etop.c
+++ b/drivers/net/ethernet/lantiq_etop.c
@@ -389,13 +389,11 @@ static int
 ltq_etop_mdio_init(struct net_device *dev)
 {
 	struct ltq_etop_priv *priv = netdev_priv(dev);
-	int err;
 
 	priv->mii_bus = devm_mdiobus_alloc(&dev->dev);
 	if (!priv->mii_bus) {
 		netdev_err(dev, "failed to allocate mii bus\n");
-		err = -ENOMEM;
-		goto err_out;
+		return -ENOMEM;
 	}
 
 	priv->mii_bus->priv = dev;
@@ -404,19 +402,13 @@ ltq_etop_mdio_init(struct net_device *dev)
 	priv->mii_bus->name = "ltq_mii";
 	snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
 		 priv->pdev->name, priv->pdev->id);
-	if (devm_mdiobus_register(&dev->dev, priv->mii_bus)) {
-		err = -ENXIO;
-		goto err_out;
-	}
+	if (devm_mdiobus_register(&dev->dev, priv->mii_bus))
+		return -ENXIO;
 
-	if (ltq_etop_mdio_probe(dev)) {
-		err = -ENXIO;
-		goto err_out;
-	}
-	return 0;
+	if (ltq_etop_mdio_probe(dev))
+		return -ENXIO;
 
-err_out:
-	return err;
+	return 0;
 }
 
 static int
@@ -634,34 +626,28 @@ ltq_etop_probe(struct platform_device *pdev)
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res) {
-		dev_err(&pdev->dev, "failed to get etop resource\n");
-		err = -ENOENT;
-		goto err_out;
+		dev_err(&pdev->dev, "failed to get etop resource");
+		return -ENOENT;
 	}
 
 	res = devm_request_mem_region(&pdev->dev, res->start,
 				      resource_size(res), dev_name(&pdev->dev));
 	if (!res) {
-		dev_err(&pdev->dev, "failed to request etop resource\n");
-		err = -EBUSY;
-		goto err_out;
+		dev_err(&pdev->dev, "failed to request etop resource");
+		return -EBUSY;
 	}
 
 	ltq_etop_membase = devm_ioremap(&pdev->dev, res->start,
 					resource_size(res));
 	if (!ltq_etop_membase) {
-		dev_err(&pdev->dev, "failed to remap etop engine %d\n",
-			pdev->id);
-		err = -ENOMEM;
-		goto err_out;
+		dev_err(&pdev->dev, "failed to remap etop engine %d", pdev->id);
+		return -ENOMEM;
 	}
 
 	dev = devm_alloc_etherdev_mqs(&pdev->dev, sizeof(struct ltq_etop_priv),
 				      4, 4);
-	if (!dev) {
-		err = -ENOMEM;
-		goto err_out;
-	}
+	if (!dev)
+		return -ENOMEM;
 	dev->netdev_ops = &ltq_eth_netdev_ops;
 	dev->ethtool_ops = &ltq_etop_ethtool_ops;
 	priv = netdev_priv(dev);
@@ -673,16 +659,14 @@ ltq_etop_probe(struct platform_device *pdev)
 	SET_NETDEV_DEV(dev, &pdev->dev);
 
 	err = device_property_read_u32(&pdev->dev, "lantiq,tx-burst-length", &priv->tx_burst_len);
-	if (err < 0) {
-		dev_err(&pdev->dev, "unable to read tx-burst-length property\n");
-		goto err_out;
-	}
+	if (err < 0)
+		return dev_err_probe(&pdev->dev, err,
+				     "unable to read tx-burst-length property");
 
 	err = device_property_read_u32(&pdev->dev, "lantiq,rx-burst-length", &priv->rx_burst_len);
-	if (err < 0) {
-		dev_err(&pdev->dev, "unable to read rx-burst-length property\n");
-		goto err_out;
-	}
+	if (err < 0)
+		return dev_err_probe(&pdev->dev, err,
+				     "unable to read rx-burst-length property");
 
 	for (i = 0; i < MAX_DMA_CHAN; i++) {
 		if (IS_TX(i))
@@ -696,13 +680,10 @@ ltq_etop_probe(struct platform_device *pdev)
 
 	err = devm_register_netdev(&pdev->dev, dev);
 	if (err)
-		goto err_out;
+		return err;
 
 	platform_set_drvdata(pdev, dev);
 	return 0;
-
-err_out:
-	return err;
 }
 
 static void ltq_etop_remove(struct platform_device *pdev)
-- 
2.46.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ