From: Rasesh Mody <rmody@marvell.com>
To: <dev@dpdk.org>
Cc: Shahed Shaikh <shshaikh@marvell.com>, <ferruh.yigit@intel.com>,
<GR-Everest-DPDK-Dev@marvell.com>, <stable@dpdk.org>
Subject: [dpdk-dev] [PATCH 2/6] net/bnx2x: fix memory leak
Date: Thu, 11 Apr 2019 18:47:38 -0700 [thread overview]
Message-ID: <1555033662-22935-2-git-send-email-rmody@marvell.com> (raw)
Message-ID: <20190412014738.u4QRPiApr7fB9M815GlDezLhrekKwPAgWsOEC64VS2c@z> (raw)
In-Reply-To: <1555033662-22935-1-git-send-email-rmody@marvell.com>
From: Shahed Shaikh <shshaikh@marvell.com>
We allocate DMA memory but never free after using it.
Add function to free DMA memory.
Fixes: b5bf7719221d ("bnx2x: driver support routines")
Cc: stable@dpdk.org
Signed-off-by: Shahed Shaikh <shshaikh@marvell.com>
---
drivers/net/bnx2x/bnx2x.c | 15 +++++++++++++++
drivers/net/bnx2x/bnx2x.h | 3 ++-
drivers/net/bnx2x/ecore_sp.h | 17 +++++++++--------
3 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/drivers/net/bnx2x/bnx2x.c b/drivers/net/bnx2x/bnx2x.c
index ab092e2..298bc41 100644
--- a/drivers/net/bnx2x/bnx2x.c
+++ b/drivers/net/bnx2x/bnx2x.c
@@ -185,6 +185,7 @@ int bnx2x_cmpxchg(volatile int *addr, int old, int new)
}
dma->paddr = (uint64_t) z->iova;
dma->vaddr = z->addr;
+ dma->mzone = (const void *)z;
PMD_DRV_LOG(DEBUG, sc,
"%s: virt=%p phys=%" PRIx64, msg, dma->vaddr, dma->paddr);
@@ -192,6 +193,19 @@ int bnx2x_cmpxchg(volatile int *addr, int old, int new)
return 0;
}
+void bnx2x_dma_free(struct bnx2x_dma *dma)
+{
+ if (dma->mzone == NULL)
+ return;
+
+ rte_memzone_free((const struct rte_memzone *)dma->mzone);
+ dma->sc = NULL;
+ dma->paddr = 0;
+ dma->vaddr = NULL;
+ dma->nseg = 0;
+ dma->mzone = NULL;
+}
+
static int bnx2x_acquire_hw_lock(struct bnx2x_softc *sc, uint32_t resource)
{
uint32_t lock_status;
@@ -2436,6 +2450,7 @@ static int bnx2x_alloc_mem(struct bnx2x_softc *sc)
static void bnx2x_free_fw_stats_mem(struct bnx2x_softc *sc)
{
+ bnx2x_dma_free(&sc->fw_stats_dma);
sc->fw_stats_num = 0;
sc->fw_stats_req_size = 0;
diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h
index 32a1229..9e82a89 100644
--- a/drivers/net/bnx2x/bnx2x.h
+++ b/drivers/net/bnx2x/bnx2x.h
@@ -319,6 +319,7 @@ struct bnx2x_dma {
rte_iova_t paddr;
void *vaddr;
int nseg;
+ const void *mzone;
char msg[RTE_MEMZONE_NAMESIZE - 6];
};
@@ -1753,7 +1754,7 @@ struct bnx2x_func_init_params {
int bnx2x_dma_alloc(struct bnx2x_softc *sc, size_t size,
struct bnx2x_dma *dma, const char *msg, uint32_t align);
-
+void bnx2x_dma_free(struct bnx2x_dma *dma);
uint32_t bnx2x_dmae_opcode_add_comp(uint32_t opcode, uint8_t comp_type);
uint32_t bnx2x_dmae_opcode_clr_src_reset(uint32_t opcode);
uint32_t bnx2x_dmae_opcode(struct bnx2x_softc *sc, uint8_t src_type,
diff --git a/drivers/net/bnx2x/ecore_sp.h b/drivers/net/bnx2x/ecore_sp.h
index f295bf5..7126097 100644
--- a/drivers/net/bnx2x/ecore_sp.h
+++ b/drivers/net/bnx2x/ecore_sp.h
@@ -151,14 +151,15 @@
} \
} while (0)
-#define ECORE_ILT_FREE(x, y, size) \
- do { \
- if (x) { \
- rte_free(x); \
- x = NULL; \
- y = 0; \
- } \
- } while (0)
+#define ECORE_ILT_FREE(x, y, size) \
+ do { \
+ if (x) { \
+ bnx2x_dma_free((struct bnx2x_dma *)x); \
+ rte_free(x); \
+ x = NULL; \
+ y = 0; \
+ } \
+ } while (0)
#define ECORE_IS_VALID_ETHER_ADDR(_mac) TRUE
--
1.7.10.3
next prev parent reply other threads:[~2019-04-12 1:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-12 1:47 [dpdk-dev] [PATCH 1/6] net/bnx2x: fix eth dev MTU Rasesh Mody
2019-04-12 1:47 ` Rasesh Mody
2019-04-12 1:47 ` Rasesh Mody [this message]
2019-04-12 1:47 ` [dpdk-dev] [PATCH 2/6] net/bnx2x: fix memory leak Rasesh Mody
2019-04-12 1:47 ` [dpdk-dev] [PATCH 3/6] net/bnx2x: fix ramrod timeout Rasesh Mody
2019-04-12 1:47 ` Rasesh Mody
2019-04-12 1:47 ` [dpdk-dev] [PATCH 4/6] net/bnx2x: fix DMAE timeout Rasesh Mody
2019-04-12 1:47 ` Rasesh Mody
2019-04-12 1:47 ` [dpdk-dev] [PATCH 5/6] net/bnx2x: fix race for periodic flags Rasesh Mody
2019-04-12 1:47 ` Rasesh Mody
2019-04-12 1:47 ` [dpdk-dev] [PATCH 6/6] net/bnx2x: fix optic module verification Rasesh Mody
2019-04-12 1:47 ` Rasesh Mody
2019-04-15 8:01 ` [dpdk-dev] [PATCH 1/6] net/bnx2x: fix eth dev MTU Ferruh Yigit
2019-04-15 8:01 ` Ferruh Yigit
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=1555033662-22935-2-git-send-email-rmody@marvell.com \
--to=rmody@marvell.com \
--cc=GR-Everest-DPDK-Dev@marvell.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=shshaikh@marvell.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).