From: Pablo de Lara <pablo.de.lara.guarch@intel.com>
To: roy.fan.zhang@intel.com
Cc: dev@dpdk.org, Pablo de Lara <pablo.de.lara.guarch@intel.com>,
stable@dpdk.org
Subject: [dpdk-dev] [PATCH 2/2] crypto/scheduler: fix memory leak
Date: Thu, 26 Apr 2018 16:09:50 +0100 [thread overview]
Message-ID: <20180426150950.7568-2-pablo.de.lara.guarch@intel.com> (raw)
In-Reply-To: <20180426150950.7568-1-pablo.de.lara.guarch@intel.com>
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 <pablo.de.lara.guarch@intel.com>
---
drivers/crypto/scheduler/scheduler_multicore.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/crypto/scheduler/scheduler_multicore.c b/drivers/crypto/scheduler/scheduler_multicore.c
index 15a57c3db..644426e93 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 = {
--
2.14.3
next prev parent reply other threads:[~2018-04-26 15:09 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-26 15:09 [dpdk-dev] [PATCH 1/2] crypto/scheduler: set null pointer after freeing Pablo de Lara
2018-04-26 15:09 ` Pablo de Lara [this message]
2018-05-08 12:45 ` [dpdk-dev] [PATCH 2/2] crypto/scheduler: fix memory leak Zhang, Roy Fan
2018-05-08 15:53 ` De Lara Guarch, Pablo
2018-04-27 8:47 ` [dpdk-dev] [PATCH 1/2] crypto/scheduler: set null pointer after freeing Akhil Goyal
2018-04-27 11:36 ` De Lara Guarch, Pablo
2018-04-27 11:58 ` Akhil Goyal
2018-04-27 12:37 ` Van Haaren, Harry
2018-04-27 13:09 ` Bruce Richardson
2018-05-08 11:28 ` Zhang, Roy Fan
2018-05-08 15:53 ` De Lara Guarch, Pablo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180426150950.7568-2-pablo.de.lara.guarch@intel.com \
--to=pablo.de.lara.guarch@intel.com \
--cc=dev@dpdk.org \
--cc=roy.fan.zhang@intel.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).