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 for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210729070627.23776-1-tangbin@cmss.chinamobile.com>
Date:   Thu, 29 Jul 2021 15:06:27 +0800
From:   Tang Bin <tangbin@...s.chinamobile.com>
To:     davem@...emloft.net, kuba@...nel.org, f.fainelli@...il.com,
        bcm-kernel-feedback-list@...adcom.com
Cc:     netdev@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        linux-kernel@...r.kernel.org,
        Tang Bin <tangbin@...s.chinamobile.com>
Subject: [PATCH] bcm63xx_enet: simplify the code in bcm_enet_open()

In the function bcm_enet_open(), 'ret = -ENOMEM' can be moved
outside the judgement statement, so redundant assignments can
be removed to simplify the code.

Signed-off-by: Tang Bin <tangbin@...s.chinamobile.com>
---
 drivers/net/ethernet/broadcom/bcm63xx_enet.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
index 509e10013..c5a3c5774 100644
--- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
@@ -920,13 +920,13 @@ static int bcm_enet_open(struct net_device *dev)
 	memcpy(addr.sa_data, dev->dev_addr, ETH_ALEN);
 	bcm_enet_set_mac_address(dev, &addr);
 
+	ret = -ENOMEM;
+
 	/* allocate rx dma ring */
 	size = priv->rx_ring_size * sizeof(struct bcm_enet_desc);
 	p = dma_alloc_coherent(kdev, size, &priv->rx_desc_dma, GFP_KERNEL);
-	if (!p) {
-		ret = -ENOMEM;
+	if (!p)
 		goto out_freeirq_tx;
-	}
 
 	priv->rx_desc_alloc_size = size;
 	priv->rx_desc_cpu = p;
@@ -934,20 +934,16 @@ static int bcm_enet_open(struct net_device *dev)
 	/* allocate tx dma ring */
 	size = priv->tx_ring_size * sizeof(struct bcm_enet_desc);
 	p = dma_alloc_coherent(kdev, size, &priv->tx_desc_dma, GFP_KERNEL);
-	if (!p) {
-		ret = -ENOMEM;
+	if (!p)
 		goto out_free_rx_ring;
-	}
 
 	priv->tx_desc_alloc_size = size;
 	priv->tx_desc_cpu = p;
 
 	priv->tx_skb = kcalloc(priv->tx_ring_size, sizeof(struct sk_buff *),
 			       GFP_KERNEL);
-	if (!priv->tx_skb) {
-		ret = -ENOMEM;
+	if (!priv->tx_skb)
 		goto out_free_tx_ring;
-	}
 
 	priv->tx_desc_count = priv->tx_ring_size;
 	priv->tx_dirty_desc = 0;
@@ -957,10 +953,8 @@ static int bcm_enet_open(struct net_device *dev)
 	/* init & fill rx ring with skbs */
 	priv->rx_skb = kcalloc(priv->rx_ring_size, sizeof(struct sk_buff *),
 			       GFP_KERNEL);
-	if (!priv->rx_skb) {
-		ret = -ENOMEM;
+	if (!priv->rx_skb)
 		goto out_free_tx_skb;
-	}
 
 	priv->rx_desc_count = 0;
 	priv->rx_dirty_desc = 0;
@@ -976,7 +970,6 @@ static int bcm_enet_open(struct net_device *dev)
 
 	if (bcm_enet_refill_rx(dev)) {
 		dev_err(kdev, "cannot allocate rx skb queue\n");
-		ret = -ENOMEM;
 		goto out;
 	}
 
-- 
2.20.1.windows.1



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ