Skip to contentSkip to conversation

bonding: fix device initialisation error handling

PATCH Applied Bernard Iremonger 3 participants 3 messages Aug 5, 2015 – Aug 10, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 bonding: fix device initialisation error handling

If the name parameter to rte_eth_bond_create() was NULL, there was a segmentation fault because eth_dev was also NULL. Add error handling of mac_addrs memory allocation. Add call to rte_eth_dev_release_port() in error handling.

---
 drivers/net/bonding/rte_eth_bond_api.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/net/bonding/rte_eth_bond_api.c +8 -2
index 4ca26dd..0681d1a 100644
@@ -239,6 +239,10 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 
 	eth_dev->data->mac_addrs = rte_zmalloc_socket(name, ETHER_ADDR_LEN, 0,
 			socket_id);
+	if (eth_dev->data->mac_addrs == NULL) {
+		RTE_BOND_LOG(ERR, "Unable to malloc mac_addrs");
+		goto err;
+	}
 
 	eth_dev->data->dev_started = 0;
 	eth_dev->data->promiscuous = 0;
@@ -285,8 +289,10 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 err:
 	rte_free(pci_dev);
 	rte_free(internals);
-	rte_free(eth_dev->data->mac_addrs);
-
+	if (eth_dev != NULL) {
+		rte_free(eth_dev->data->mac_addrs);
+		rte_eth_dev_release_port(eth_dev);
+	}
 	return -1;
 }
 
Signature · 1 line
1.9.1
Acked-by on v3 1/1
#1 lore raw
Quoted 7 lines

-----Original Message-----
From: Iremonger, Bernard
Sent: Wednesday, August 05, 2015 4:04 PM
To: [email protected]
Cc: Jastrzebski, MichalX K; Liu, Yong; Iremonger, Bernard
Subject: [PATCH v3 1/1] bonding: fix device initialisation error handling

Quoted 6 lines

If the name parameter to rte_eth_bond_create() was NULL, there was a segmentation fault because eth_dev was also NULL. Add error handling of mac_addrs memory allocation. Add call to rte_eth_dev_release_port() in error handling.