From: wangyunjian <wangyunjian@huawei.com>
To: <dev@dpdk.org>
Cc: <nicolas.chautru@intel.com>, <jerry.lilijun@huawei.com>,
<xudingke@huawei.com>, Yunjian Wang <wangyunjian@huawei.com>,
<stable@dpdk.org>
Subject: [dpdk-dev] [PATCH] baseband/turbo_sw: fix memory leak in error path
Date: Wed, 7 Oct 2020 17:03:38 +0800 [thread overview]
Message-ID: <1cad32e57c8081477a0f448b5b3d61711ef6b382.1602060933.git.wangyunjian@huawei.com> (raw)
From: Yunjian Wang <wangyunjian@huawei.com>
In q_setup() allocated memory for the queue data, we should free
it when error happens, otherwise it will lead to memory leak.
Fixes: b8cfe2c9aed2 ("bb/turbo_sw: add software turbo driver")
Cc: stable@dpdk.org
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
drivers/baseband/turbo_sw/bbdev_turbo_software.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/baseband/turbo_sw/bbdev_turbo_software.c b/drivers/baseband/turbo_sw/bbdev_turbo_software.c
index a36099e91..e55b32927 100644
--- a/drivers/baseband/turbo_sw/bbdev_turbo_software.c
+++ b/drivers/baseband/turbo_sw/bbdev_turbo_software.c
@@ -302,7 +302,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id,
rte_bbdev_log(ERR,
"Creating queue name for device %u queue %u failed",
dev->data->dev_id, q_id);
- return -ENAMETOOLONG;
+ goto free_q;
}
q->enc_out = rte_zmalloc_socket(name,
((RTE_BBDEV_TURBO_MAX_TB_SIZE >> 3) + 3) *
@@ -322,7 +322,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id,
rte_bbdev_log(ERR,
"Creating queue name for device %u queue %u failed",
dev->data->dev_id, q_id);
- return -ENAMETOOLONG;
+ goto free_q;
}
q->enc_in = rte_zmalloc_socket(name,
(RTE_BBDEV_LDPC_MAX_CB_SIZE >> 3) * sizeof(*q->enc_in),
@@ -340,7 +340,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id,
rte_bbdev_log(ERR,
"Creating queue name for device %u queue %u failed",
dev->data->dev_id, q_id);
- return -ENAMETOOLONG;
+ goto free_q;
}
q->ag = rte_zmalloc_socket(name,
RTE_BBDEV_TURBO_MAX_CB_SIZE * 10 * sizeof(*q->ag),
@@ -358,7 +358,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id,
rte_bbdev_log(ERR,
"Creating queue name for device %u queue %u failed",
dev->data->dev_id, q_id);
- return -ENAMETOOLONG;
+ goto free_q;
}
q->code_block = rte_zmalloc_socket(name,
RTE_BBDEV_TURBO_MAX_CB_SIZE * sizeof(*q->code_block),
@@ -377,7 +377,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id,
rte_bbdev_log(ERR,
"Creating queue name for device %u queue %u failed",
dev->data->dev_id, q_id);
- return -ENAMETOOLONG;
+ goto free_q;
}
q->deint_input = rte_zmalloc_socket(name,
DEINT_INPUT_BUF_SIZE * sizeof(*q->deint_input),
@@ -396,7 +396,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id,
rte_bbdev_log(ERR,
"Creating queue name for device %u queue %u failed",
dev->data->dev_id, q_id);
- return -ENAMETOOLONG;
+ goto free_q;
}
q->deint_output = rte_zmalloc_socket(NULL,
DEINT_OUTPUT_BUF_SIZE * sizeof(*q->deint_output),
@@ -415,7 +415,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id,
rte_bbdev_log(ERR,
"Creating queue name for device %u queue %u failed",
dev->data->dev_id, q_id);
- return -ENAMETOOLONG;
+ goto free_q;
}
q->adapter_output = rte_zmalloc_socket(NULL,
ADAPTER_OUTPUT_BUF_SIZE * sizeof(*q->adapter_output),
@@ -433,7 +433,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id,
rte_bbdev_log(ERR,
"Creating queue name for device %u queue %u failed",
dev->data->dev_id, q_id);
- return -ENAMETOOLONG;
+ goto free_q;
}
q->processed_pkts = rte_ring_create(name, queue_conf->queue_size,
queue_conf->socket, RING_F_SP_ENQ | RING_F_SC_DEQ);
--
2.23.0
next reply other threads:[~2020-10-07 9:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-07 9:03 wangyunjian [this message]
2020-10-07 23:45 ` Chautru, Nicolas
2020-10-15 12:50 ` wangyunjian
2020-10-15 13:45 ` [dpdk-dev] [PATCH v2] " wangyunjian
2020-10-17 0:22 ` Chautru, Nicolas
2020-10-28 11:29 ` Akhil Goyal
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=1cad32e57c8081477a0f448b5b3d61711ef6b382.1602060933.git.wangyunjian@huawei.com \
--to=wangyunjian@huawei.com \
--cc=dev@dpdk.org \
--cc=jerry.lilijun@huawei.com \
--cc=nicolas.chautru@intel.com \
--cc=stable@dpdk.org \
--cc=xudingke@huawei.com \
/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).