From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 3C4E2A0096 for ; Fri, 12 Apr 2019 03:48:25 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F233C4F94; Fri, 12 Apr 2019 03:48:24 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 74E843772; Fri, 12 Apr 2019 03:48:23 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x3C1ZmVf021506; Thu, 11 Apr 2019 18:48:22 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=7+l3L2kS/xlw3yzm3nmmi/ZMqStVMaH8TbOSCvt6okU=; b=U1edy+0Zj0ba0iKNAyh55iK17WuGSfC3tzZpewqVJp9wyf90E8LjYfYhDL/tcYncBQdJ 2TG6GfcPBXsAD/AhOAijzJIz8MzbYOJr/7rcxiN3txLUEm6KiYXW7Yfr2/MhUzM2p/sk 6VDJj3Hko9/BH1fj8JsZqJI/myANVllAce4h8i4gvnftIlt8G+I8w5r7v1332HiBNBSv QiuoVsIqZUQy3ucDLdM/oth/uYoJDrM/g/+HtajQE9ovt1BZtpxQwEOgPU6Sdv6Pn5Cp 0zSjgpjlepN58rXRSW+EbNMrbCqL5n1w2NXy8bWgMS0wyA9dUZV7gZrE+aXWWHtqAvr0 VA== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 2rt2xvb3ab-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 11 Apr 2019 18:48:22 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 11 Apr 2019 18:48:21 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 11 Apr 2019 18:48:21 -0700 Received: from irv1user08.caveonetworks.com (unknown [10.104.116.105]) by maili.marvell.com (Postfix) with ESMTP id 1D81C3F7040; Thu, 11 Apr 2019 18:48:21 -0700 (PDT) Received: (from rmody@localhost) by irv1user08.caveonetworks.com (8.14.4/8.14.4/Submit) id x3C1mLHx022998; Thu, 11 Apr 2019 18:48:21 -0700 X-Authentication-Warning: irv1user08.caveonetworks.com: rmody set sender to rmody@marvell.com using -f From: Rasesh Mody To: CC: Shahed Shaikh , , , Date: Thu, 11 Apr 2019 18:47:38 -0700 Message-ID: <1555033662-22935-2-git-send-email-rmody@marvell.com> X-Mailer: git-send-email 1.7.10.3 In-Reply-To: <1555033662-22935-1-git-send-email-rmody@marvell.com> References: <1555033662-22935-1-git-send-email-rmody@marvell.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-04-12_01:, , signatures=0 Subject: [dpdk-dev] [PATCH 2/6] net/bnx2x: fix memory leak X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Message-ID: <20190412014738.u4QRPiApr7fB9M815GlDezLhrekKwPAgWsOEC64VS2c@z> From: Shahed Shaikh 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 --- 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