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-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20170330064929.20309.58065.stgit@ltcalpine2-lp23.aus.stglabs.ibm.com>
Date:   Thu, 30 Mar 2017 02:49:29 -0400
From:   Nathan Fontenot <nfont@...ux.vnet.ibm.com>
To:     netdev@...r.kernel.org
Cc:     jallen@...ux.vnet.ibm.com, tlfalcon@...ux.vnet.ibm.com
Subject: [PATCH net 7/7] ibmvnic: Cleanup failure path in ibmvnic_open

Now that ibmvnic_release_resources will clean up all of our resources
properly, even if they were not allocated, we can just call this
for failues in ibmvnic_open.

This patch also moves the ibmvnic_release_resources() routine up
in the file to avoid creating a forward declaration ad re-names it to
drop the ibmvnic prefix.

Signed-off-by: Nathan Fontenot <nfont@...ux.vnet.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c |   51 +++++++++++++-----------------------
 1 file changed, 19 insertions(+), 32 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index a2f972d..7ba43cf 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -578,13 +578,23 @@ static int ibmvnic_login(struct net_device *netdev)
 	return 0;
 }
 
+static void release_resources(struct ibmvnic_adapter *adapter)
+{
+	release_bounce_buffer(adapter);
+	release_tx_pools(adapter);
+	release_rx_pools(adapter);
+
+	release_sub_crqs(adapter);
+	release_crq_queue(adapter);
+
+	release_stats_token(adapter);
+}
+
 static int ibmvnic_open(struct net_device *netdev)
 {
 	struct ibmvnic_adapter *adapter = netdev_priv(netdev);
 	struct device *dev = &adapter->vdev->dev;
 	union ibmvnic_crq crq;
-	int rxadd_subcrqs;
-	int tx_subcrqs;
 	int rc = 0;
 	int i;
 
@@ -610,16 +620,11 @@ static int ibmvnic_open(struct net_device *netdev)
 		return -1;
 	}
 
-	rxadd_subcrqs =
-	    be32_to_cpu(adapter->login_rsp_buf->num_rxadd_subcrqs);
-	tx_subcrqs =
-	    be32_to_cpu(adapter->login_rsp_buf->num_txsubm_subcrqs);
-
 	adapter->map_id = 1;
 	adapter->napi = kcalloc(adapter->req_rx_queues,
 				sizeof(struct napi_struct), GFP_KERNEL);
 	if (!adapter->napi)
-		goto alloc_napi_failed;
+		goto ibmvnic_open_fail;
 	for (i = 0; i < adapter->req_rx_queues; i++) {
 		netif_napi_add(netdev, &adapter->napi[i], ibmvnic_poll,
 			       NAPI_POLL_WEIGHT);
@@ -630,15 +635,15 @@ static int ibmvnic_open(struct net_device *netdev)
 
 	rc = init_rx_pools(netdev);
 	if (rc)
-		goto rx_pool_failed;
+		goto ibmvnic_open_fail;
 
 	rc = init_tx_pools(netdev);
 	if (rc)
-		goto tx_pool_failed;
+		goto ibmvnic_open_fail;
 
 	rc = init_bounce_buffer(netdev);
 	if (rc)
-		goto bounce_init_failed;
+		goto ibmvnic_open_fail;
 
 	replenish_pools(adapter);
 
@@ -662,31 +667,13 @@ static int ibmvnic_open(struct net_device *netdev)
 
 	return 0;
 
-bounce_init_failed:
-	i = tx_subcrqs - 1;
-	kfree(adapter->tx_pool[i].free_map);
-tx_pool_failed:
-	i = rxadd_subcrqs;
-rx_pool_failed:
+ibmvnic_open_fail:
 	for (i = 0; i < adapter->req_rx_queues; i++)
 		napi_disable(&adapter->napi[i]);
-alloc_napi_failed:
-	release_sub_crqs(adapter);
+	release_resources(adapter);
 	return -ENOMEM;
 }
 
-static void ibmvnic_release_resources(struct ibmvnic_adapter *adapter)
-{
-	release_bounce_buffer(adapter);
-	release_tx_pools(adapter);
-	release_rx_pools(adapter);
-
-	release_sub_crqs(adapter);
-	release_crq_queue(adapter);
-
-	release_stats_token(adapter);
-}
-
 static int ibmvnic_close(struct net_device *netdev)
 {
 	struct ibmvnic_adapter *adapter = netdev_priv(netdev);
@@ -707,7 +694,7 @@ static int ibmvnic_close(struct net_device *netdev)
 	crq.logical_link_state.link_state = IBMVNIC_LOGICAL_LNK_DN;
 	ibmvnic_send_crq(adapter, &crq);
 
-	ibmvnic_release_resources(adapter);
+	release_resources(adapter);
 
 	adapter->is_closed = true;
 	adapter->closing = false;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ