From patchwork Tue Dec 1 00:59:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunjian Wang X-Patchwork-Id: 84644 X-Patchwork-Delegate: ajit.khaparde@broadcom.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C2DA0A04DB; Tue, 1 Dec 2020 01:59:49 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 188A0C954; Tue, 1 Dec 2020 01:59:48 +0100 (CET) Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by dpdk.org (Postfix) with ESMTP id D1F8AC952; Tue, 1 Dec 2020 01:59:44 +0100 (CET) Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4ClNzF6zmJzhlBM; Tue, 1 Dec 2020 08:59:21 +0800 (CST) Received: from localhost (10.174.187.156) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.487.0; Tue, 1 Dec 2020 08:59:35 +0800 From: wangyunjian To: CC: , , , , Yunjian Wang , Date: Tue, 1 Dec 2020 08:59:34 +0800 Message-ID: <1606784374-32388-1-git-send-email-wangyunjian@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 MIME-Version: 1.0 X-Originating-IP: [10.174.187.156] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH] net/bnxt: fix memory leak when mapping failure 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" From: Yunjian Wang We allocated memory for the 'buf' when sending message to HWRM, but we don't free it when mapping the address to IO address fails. It will lead to memory leak. Fixes: 19e6af01bb36 ("net/bnxt: support get/set EEPROM") Cc: stable@dpdk.org Signed-off-by: Yunjian Wang --- drivers/net/bnxt/bnxt_hwrm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 24c33185b4..ebbf504c0c 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -4320,6 +4320,7 @@ int bnxt_get_nvram_directory(struct bnxt *bp, uint32_t len, uint8_t *data) return -ENOMEM; dma_handle = rte_malloc_virt2iova(buf); if (dma_handle == RTE_BAD_IOVA) { + rte_free(buf); PMD_DRV_LOG(ERR, "unable to map response address to physical memory\n"); return -ENOMEM; @@ -4354,6 +4355,7 @@ int bnxt_hwrm_get_nvram_item(struct bnxt *bp, uint32_t index, dma_handle = rte_malloc_virt2iova(buf); if (dma_handle == RTE_BAD_IOVA) { + rte_free(buf); PMD_DRV_LOG(ERR, "unable to map response address to physical memory\n"); return -ENOMEM; @@ -4407,6 +4409,7 @@ int bnxt_hwrm_flash_nvram(struct bnxt *bp, uint16_t dir_type, dma_handle = rte_malloc_virt2iova(buf); if (dma_handle == RTE_BAD_IOVA) { + rte_free(buf); PMD_DRV_LOG(ERR, "unable to map response address to physical memory\n"); return -ENOMEM;