From: Pablo de Lara Date: Thu, 26 Apr 2018 15:09:50 +0000 (+0100) Subject: crypto/scheduler: fix memory leak X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=7b2491a62dcc4da2ad5afca2dbba458588126c23;p=dpdk.git crypto/scheduler: fix memory leak If private context creation fails, the memory allocated for it and for some of the rings created was being leaked. In case of failure, it must be freed. Fixes: 4c07e0552f0a ("crypto/scheduler: add multicore scheduling mode") Cc: stable@dpdk.org Signed-off-by: Pablo de Lara Acked-by: Fan Zhang --- diff --git a/drivers/crypto/scheduler/scheduler_multicore.c b/drivers/crypto/scheduler/scheduler_multicore.c index 15a57c3db8..644426e93b 100644 --- a/drivers/crypto/scheduler/scheduler_multicore.c +++ b/drivers/crypto/scheduler/scheduler_multicore.c @@ -352,20 +352,29 @@ scheduler_create_private_ctx(struct rte_cryptodev *dev) rte_socket_id(), RING_F_SC_DEQ | RING_F_SP_ENQ); if (!mc_ctx->sched_enq_ring[i]) { CS_LOG_ERR("Cannot create ring for worker %u", i); - return -1; + goto exit; } snprintf(r_name, sizeof(r_name), MC_SCHED_DEQ_RING_NAME_PREFIX "%u", i); mc_ctx->sched_deq_ring[i] = rte_ring_create(r_name, PER_SLAVE_BUFF_SIZE, rte_socket_id(), RING_F_SC_DEQ | RING_F_SP_ENQ); if (!mc_ctx->sched_deq_ring[i]) { CS_LOG_ERR("Cannot create ring for worker %u", i); - return -1; + goto exit; } } sched_ctx->private_ctx = (void *)mc_ctx; return 0; + +exit: + for (i = 0; i < sched_ctx->nb_wc; i++) { + rte_ring_free(mc_ctx->sched_enq_ring[i]); + rte_ring_free(mc_ctx->sched_deq_ring[i]); + } + rte_free(mc_ctx); + + return -1; } struct rte_cryptodev_scheduler_ops scheduler_mc_ops = {