summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernard Iremonger <bernard.iremonger@intel.com>2015-08-05 15:04:03 +0100
committerThomas Monjalon <thomas.monjalon@6wind.com>2015-08-10 02:05:42 +0200
commitc45c8bd9b96e0bdf97572de25aaa771f63b37466 (patch)
tree573803fefb2a1c092a00f73c78d184b7262cf7eb
parent85cc012ddda48ee6930789187bbfb661066e1c02 (diff)
downloaddpdk-c45c8bd9b96e0bdf97572de25aaa771f63b37466.zip
dpdk-c45c8bd9b96e0bdf97572de25aaa771f63b37466.tar.gz
dpdk-c45c8bd9b96e0bdf97572de25aaa771f63b37466.tar.xz
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. Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com> Tested-by: Marvin Liu <yong.liu@intel.com> Acked-by: Michal Jastrzebski <michalx.k.jastrzebski@intel.com>
-rw-r--r--drivers/net/bonding/rte_eth_bond_api.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index 4ca26dd..0681d1a 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -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;
}