Skip to content

Commit

Permalink
net/ixgbe: fix memoy leak after device init failure
Browse files Browse the repository at this point in the history
[ upstream commit 4d70ae0f1bb88e2aa100f5f7bf50b6484f0685cd ]

In ixgbe_ipsec_ctx_create() allocated memory for the 'security_ctx',
we should free it when errors occur, otherwise it will lead
to memory leak.

Fixes: 9a0752f ("net/ixgbe: enable inline IPsec")

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
  • Loading branch information
wyjwang authored and bluca committed Feb 27, 2024
1 parent ae83695 commit 6bc4e06
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions drivers/net/ixgbe/ixgbe_ethdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,8 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)
diag = ixgbe_validate_eeprom_checksum(hw, &csum);
if (diag != IXGBE_SUCCESS) {
PMD_INIT_LOG(ERR, "The EEPROM checksum is not valid: %d", diag);
return -EIO;
ret = -EIO;
goto err_exit;
}

#ifdef RTE_LIBRTE_IXGBE_BYPASS
Expand Down Expand Up @@ -1225,7 +1226,8 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)
PMD_INIT_LOG(ERR, "Unsupported SFP+ Module");
if (diag) {
PMD_INIT_LOG(ERR, "Hardware Initialization Failure: %d", diag);
return -EIO;
ret = -EIO;
goto err_exit;
}

/* Reset the hw statistics */
Expand All @@ -1245,7 +1247,8 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)
"Failed to allocate %u bytes needed to store "
"MAC addresses",
RTE_ETHER_ADDR_LEN * hw->mac.num_rar_entries);
return -ENOMEM;
ret = -ENOMEM;
goto err_exit;
}
/* Copy the permanent MAC address */
rte_ether_addr_copy((struct rte_ether_addr *)hw->mac.perm_addr,
Expand All @@ -1260,7 +1263,8 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)
RTE_ETHER_ADDR_LEN * IXGBE_VMDQ_NUM_UC_MAC);
rte_free(eth_dev->data->mac_addrs);
eth_dev->data->mac_addrs = NULL;
return -ENOMEM;
ret = -ENOMEM;
goto err_exit;
}

/* initialize the vfta */
Expand Down Expand Up @@ -1344,6 +1348,11 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)
eth_dev->data->mac_addrs = NULL;
rte_free(eth_dev->data->hash_mac_addrs);
eth_dev->data->hash_mac_addrs = NULL;
err_exit:
#ifdef RTE_LIB_SECURITY
rte_free(eth_dev->security_ctx);
eth_dev->security_ctx = NULL;
#endif
return ret;
}

Expand Down

0 comments on commit 6bc4e06

Please sign in to comment.