Skip to content

Commit

Permalink
netdev-dpdk: Fix memory leak in dpdk_mp_{get, put}().
Browse files Browse the repository at this point in the history
'dmp' should be freed on failure and on put.

Fixes: 8a9562d ("dpif-netdev: Add DPDK netdev.")
Fixes: 8d38823 ("netdev-dpdk: fix memory leak")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
  • Loading branch information
igsilya authored and ddiproietto committed Sep 19, 2016
1 parent 5db206d commit e166f35
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/netdev-dpdk.c
Expand Up @@ -498,7 +498,7 @@ dpdk_mp_get(int socket_id, int mtu) OVS_REQUIRES(dpdk_mutex)
do {
if (snprintf(mp_name, RTE_MEMPOOL_NAMESIZE, "ovs_mp_%d_%d_%u",
dmp->mtu, dmp->socket_id, mp_size) < 0) {
return NULL;
goto fail;
}

dmp->mp = rte_mempool_create(mp_name, mp_size, MBUF_SIZE(mtu),
Expand All @@ -510,13 +510,17 @@ dpdk_mp_get(int socket_id, int mtu) OVS_REQUIRES(dpdk_mutex)
} while (!dmp->mp && rte_errno == ENOMEM && (mp_size /= 2) >= MIN_NB_MBUF);

if (dmp->mp == NULL) {
return NULL;
goto fail;
} else {
VLOG_DBG("Allocated \"%s\" mempool with %u mbufs", mp_name, mp_size );
}

ovs_list_push_back(&dpdk_mp_list, &dmp->list_node);
return dmp;

fail:
rte_free(dmp);
return NULL;
}

static void
Expand All @@ -531,6 +535,7 @@ dpdk_mp_put(struct dpdk_mp *dmp) OVS_REQUIRES(dpdk_mutex)
if (!--dmp->refcount) {
ovs_list_remove(&dmp->list_node);
rte_mempool_free(dmp->mp);
rte_free(dmp);
}
}

Expand Down

0 comments on commit e166f35

Please sign in to comment.