From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rnd-relay.smtp.broadcom.com (rnd-relay.smtp.broadcom.com [192.19.229.170]) by dpdk.org (Postfix) with ESMTP id AA4D825D9; Thu, 26 Jul 2018 03:15:59 +0200 (CEST) Received: from nis-sj1-27.broadcom.com (nis-sj1-27.lvn.broadcom.net [10.75.144.136]) by rnd-relay.smtp.broadcom.com (Postfix) with ESMTP id 11B8730C026; Wed, 25 Jul 2018 18:15:53 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com 11B8730C026 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1532567753; bh=ZnJYEYqXuAhWCRqhj8g67nvErVk2rVlS3EP8nfjXkM4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IXYXhwZiSrPUnTc39sj8+npgqpSmzg8HFolvJR+0DQ/5zW3PTy2gYQR4sEkV9YJny htb7HzWoet4yNaiembSkp/CC3jRBixSEnVdZymJg2eJ2rhKc81cr6L8zq9AYFLQAlZ /mVyn4pyMtusHc5lk9q3OrZwiC9wfWE3Jo4eLvrg= Received: from C02VPB22HTD6.vpn.broadcom.net (unknown [10.10.118.171]) by nis-sj1-27.broadcom.com (Postfix) with ESMTP id C8E56AC06AD; Wed, 25 Jul 2018 18:15:52 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: stable@dpdk.org Date: Wed, 25 Jul 2018 18:15:45 -0700 Message-Id: <20180726011548.97788-3-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.15.2 (Apple Git-101.1) In-Reply-To: <20180726011548.97788-1-ajit.khaparde@broadcom.com> References: <20180726011548.97788-1-ajit.khaparde@broadcom.com> Subject: [dpdk-dev] [PATCH 2/5] net/bnxt: fix to free allocated memory 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: , X-List-Received-Date: Thu, 26 Jul 2018 01:16:00 -0000 In some cases we may not be freeing up memory allocated for certain NVM commands because the code might have bailed out before reaching rte_free(). This patch moves some code around to ensure the allocated memory is freed before exiting the function. Fixes: 19e6af01bb36 ("net/bnxt: support get/set EEPROM") Cc: stable@dpdk.org Reviewed-by: Somnath Kotur Reviewed-by: Ray Jui Reviewed-by: Michael Wildt Reviewed-by: Randy Schacher Signed-off-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_hwrm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 69c83cdab..3f8e26ca3 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -3353,13 +3353,12 @@ int bnxt_get_nvram_directory(struct bnxt *bp, uint32_t len, uint8_t *data) req.host_dest_addr = rte_cpu_to_le_64(dma_handle); rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); - HWRM_CHECK_RESULT(); - HWRM_UNLOCK(); - if (rc == 0) memcpy(data, buf, len > buflen ? buflen : len); rte_free(buf); + HWRM_CHECK_RESULT(); + HWRM_UNLOCK(); return rc; } @@ -3391,12 +3390,13 @@ int bnxt_hwrm_get_nvram_item(struct bnxt *bp, uint32_t index, req.offset = rte_cpu_to_le_32(offset); req.len = rte_cpu_to_le_32(length); rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); - HWRM_CHECK_RESULT(); - HWRM_UNLOCK(); if (rc == 0) memcpy(data, buf, length); rte_free(buf); + HWRM_CHECK_RESULT(); + HWRM_UNLOCK(); + return rc; } @@ -3451,10 +3451,10 @@ int bnxt_hwrm_flash_nvram(struct bnxt *bp, uint16_t dir_type, rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + rte_free(buf); HWRM_CHECK_RESULT(); HWRM_UNLOCK(); - rte_free(buf); return rc; } -- 2.15.2 (Apple Git-101.1)