[03/20] crypto/dpaa2_sec: fix memory leaks in error handlings
Checks
Commit Message
When function returned from error handling branches, the memories were
not freed which caused a memory leak.
Fixes: 8d1f3a5d751b ("crypto/dpaa2_sec: support crypto operation")
Signed-off-by: Weiguo Li <liwg06@foxmail.com>
---
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 3 +++
1 file changed, 3 insertions(+)
Comments
On Tue, Feb 22, 2022 at 7:19 PM Weiguo Li <liwg06@foxmail.com> wrote:
>
> When function returned from error handling branches, the memories were
> not freed which caused a memory leak.
>
> Fixes: 8d1f3a5d751b ("crypto/dpaa2_sec: support crypto operation")
This is backport material.
Please add Cc: stable@dpdk.org in new revision.
>
> Signed-off-by: Weiguo Li <liwg06@foxmail.com>
> ---
> drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
> index e62d04852b..3f8d4d213f 100644
> --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
> +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
> @@ -2037,12 +2037,15 @@ dpaa2_sec_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id,
> RTE_CACHE_LINE_SIZE);
> if (!qp->rx_vq.q_storage) {
> DPAA2_SEC_ERR("malloc failed for q_storage");
> + rte_free(qp);
> return -ENOMEM;
> }
> memset(qp->rx_vq.q_storage, 0, sizeof(struct queue_storage_info_t));
>
> if (dpaa2_alloc_dq_storage(qp->rx_vq.q_storage)) {
> DPAA2_SEC_ERR("Unable to allocate dequeue storage");
> + rte_free(qp->rx_vq.q_storage);
> + rte_free(qp);
> return -ENOMEM;
> }
Please rebase this fix, there was a new allocation introduced in this
code and I suspect this should be fixed too.
Thanks.
@@ -2037,12 +2037,15 @@ dpaa2_sec_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id,
RTE_CACHE_LINE_SIZE);
if (!qp->rx_vq.q_storage) {
DPAA2_SEC_ERR("malloc failed for q_storage");
+ rte_free(qp);
return -ENOMEM;
}
memset(qp->rx_vq.q_storage, 0, sizeof(struct queue_storage_info_t));
if (dpaa2_alloc_dq_storage(qp->rx_vq.q_storage)) {
DPAA2_SEC_ERR("Unable to allocate dequeue storage");
+ rte_free(qp->rx_vq.q_storage);
+ rte_free(qp);
return -ENOMEM;
}