dpdk: NULL freed variables

The DPDKDeviceResourcesDeinit function now accepts second-level
reference to NULL the provided variable after deinitialization..
pull/12888/head
Lukas Sismis 3 months ago committed by Victor Julien
parent fbe5ce7a2b
commit e6811c51c6

@ -336,7 +336,7 @@ static void DPDKDerefConfig(void *conf)
DPDKIfaceConfig *iconf = (DPDKIfaceConfig *)conf;
if (SC_ATOMIC_SUB(iconf->ref, 1) == 1) {
DPDKDeviceResourcesDeinit(iconf->pkt_mempools);
DPDKDeviceResourcesDeinit(&iconf->pkt_mempools);
SCFree(iconf);
}
SCReturn;
@ -1464,6 +1464,7 @@ static int DeviceConfigureQueues(DPDKIfaceConfig *iconf, const struct rte_eth_de
if (retval < 0) {
SCLogError("%s: failed to setup TX queue %u: %s", iconf->iface, queue_id,
rte_strerror(-retval));
retval = -1; // the error code explained, informing about failure
goto cleanup;
}
}
@ -1471,7 +1472,7 @@ static int DeviceConfigureQueues(DPDKIfaceConfig *iconf, const struct rte_eth_de
SCReturnInt(0);
cleanup:
DPDKDeviceResourcesDeinit(iconf->pkt_mempools);
DPDKDeviceResourcesDeinit(&iconf->pkt_mempools);
SCReturnInt(retval);
}

@ -47,21 +47,22 @@ int DPDKDeviceResourcesInit(DPDKDeviceResources **dpdk_vars, uint16_t mp_cnt)
SCReturnInt(0);
}
void DPDKDeviceResourcesDeinit(DPDKDeviceResources *dpdk_vars)
void DPDKDeviceResourcesDeinit(DPDKDeviceResources **dpdk_vars)
{
if (dpdk_vars != NULL) {
if (dpdk_vars->pkt_mp != NULL) {
for (int j = 0; j < dpdk_vars->pkt_mp_capa; j++) {
if (dpdk_vars->pkt_mp[j] != NULL) {
rte_mempool_free(dpdk_vars->pkt_mp[j]);
if ((*dpdk_vars) != NULL) {
if ((*dpdk_vars)->pkt_mp != NULL) {
for (int j = 0; j < (*dpdk_vars)->pkt_mp_capa; j++) {
if ((*dpdk_vars)->pkt_mp[j] != NULL) {
rte_mempool_free((*dpdk_vars)->pkt_mp[j]);
}
}
SCFree(dpdk_vars->pkt_mp);
dpdk_vars->pkt_mp_capa = 0;
dpdk_vars->pkt_mp_cnt = 0;
dpdk_vars->pkt_mp = NULL;
SCFree((*dpdk_vars)->pkt_mp);
(*dpdk_vars)->pkt_mp_capa = 0;
(*dpdk_vars)->pkt_mp_cnt = 0;
(*dpdk_vars)->pkt_mp = NULL;
}
SCFree(dpdk_vars);
SCFree(*dpdk_vars);
*dpdk_vars = NULL;
}
}

@ -124,7 +124,7 @@ typedef struct {
} DPDKDeviceResources;
int DPDKDeviceResourcesInit(DPDKDeviceResources **dpdk_vars, uint16_t mp_cnt);
void DPDKDeviceResourcesDeinit(DPDKDeviceResources *dpdk_vars);
void DPDKDeviceResourcesDeinit(DPDKDeviceResources **dpdk_vars);
#endif /* HAVE_DPDK */

@ -60,7 +60,7 @@ void DPDKFreeDevice(LiveDevice *ldev)
#ifdef HAVE_DPDK
if (SCRunmodeGet() == RUNMODE_DPDK) {
SCLogDebug("%s: releasing packet mempools", ldev->dev);
DPDKDeviceResourcesDeinit(ldev->dpdk_vars);
DPDKDeviceResourcesDeinit(&ldev->dpdk_vars);
}
#endif
}

Loading…
Cancel
Save