DPDK patches and discussions
 help / color / mirror / Atom feed
From: Anoob Joseph <anoobj@marvell.com>
To: Jerin Jacob <jerinj@marvell.com>
Cc: Anoob Joseph <anoobj@marvell.com>, <dev@dpdk.org>, <schalla@marvell.com>
Subject: [dpdk-dev] [PATCH] common/cnxk: fix memory leak
Date: Wed, 10 Nov 2021 09:38:35 +0530	[thread overview]
Message-ID: <1636517315-414-1-git-send-email-anoobj@marvell.com> (raw)

The memory allocated for temporarily keeping DPTR need to be freed after
operation.

Also, dptr need to be aligned to 8B.

Fixes: e0bf49f7622b ("common/cnxk: add code to write CPT CTX through microcode op")
Cc: schalla@marvell.com

Signed-off-by: Anoob Joseph <anoobj@marvell.com>
Reviewed-by: Nithin Kumar Dabilpuram <ndabilpuram@marvell.com>
Reviewed-by: Tejasree Kondoj <ktejasree@marvell.com>
---
 drivers/common/cnxk/roc_cpt.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/common/cnxk/roc_cpt.c b/drivers/common/cnxk/roc_cpt.c
index 5c8c328..51cd612 100644
--- a/drivers/common/cnxk/roc_cpt.c
+++ b/drivers/common/cnxk/roc_cpt.c
@@ -930,12 +930,14 @@ roc_cpt_ctx_write(struct roc_cpt_lf *lf, void *sa_dptr, void *sa_cptr,
 		plt_err("Couldn't allocate memory for result address");
 		return -ENOMEM;
 	}
-	dptr = plt_zmalloc(sa_len, 0);
-	if (!dptr) {
+
+	dptr = plt_zmalloc(sa_len, 8);
+	if (dptr == NULL) {
 		plt_err("Couldn't allocate memory for SA dptr");
 		plt_free(res);
 		return -ENOMEM;
 	}
+
 	for (i = 0; i < (sa_len / 8); i++)
 		dptr[i] = plt_cpu_to_be_64(((uint64_t *)sa_dptr)[i]);
 
@@ -962,6 +964,7 @@ roc_cpt_ctx_write(struct roc_cpt_lf *lf, void *sa_dptr, void *sa_cptr,
 		plt_delay_ms(1);
 
 	plt_free(res);
+	plt_free(dptr);
 
 	return 0;
 }
-- 
2.7.4


             reply	other threads:[~2021-11-10  4:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-10  4:08 Anoob Joseph [this message]
2021-11-10  4:32 ` [dpdk-dev] [PATCH v2] " Anoob Joseph
2021-11-11 15:18 ` [dpdk-dev] [PATCH] " Jerin Jacob

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=1636517315-414-1-git-send-email-anoobj@marvell.com \
    --to=anoobj@marvell.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=schalla@marvell.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).