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 A77D01C01; 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 D68DB30C02B; Wed, 25 Jul 2018 18:15:53 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com D68DB30C02B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1532567753; bh=CVBiiTSN0OWzvFxrNc9advAcIL8GWzr5mphmRu2myOs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hlp7pO8w0nOD7Uf+uZnxd4IJ/cc77upTFD9tsTBITLl/8qfvPDMVgg9Gfr+Ffgwm3 RyzLEe/qShkPwDhNKxYB2RjYFx/u9B4/UrJphGbKsofPjAWrH3jJna5Zzzl1zDbcKN F6CT8cKpdCfBXjLAc0Ga0jkvH1lDl8YB+jlg7POA= Received: from C02VPB22HTD6.vpn.broadcom.net (unknown [10.10.118.171]) by nis-sj1-27.broadcom.com (Postfix) with ESMTP id 60254AC0761; Wed, 25 Jul 2018 18:15:53 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: stable@dpdk.org Date: Wed, 25 Jul 2018 18:15:46 -0700 Message-Id: <20180726011548.97788-4-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 3/5] net/bnxt: fix to release lock when alloc fails in NVM write 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 bnxt_hwrm_flash_nvram, before attempting to allocate a buffer we are grabbing the rte_spinlock. And if the allocation fails we are returning before releasing the spinlock. We avoid the situation by calling HWRM_PREP which grabs the lock after the buffer is allocated successfully. Fixes: 19e6af01bb36 ("net/bnxt: support get/set EEPROM") Cc: stable@dpdk.org Reviewed-by: Randy Schacher Signed-off-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_hwrm.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 3f8e26ca3..5e8970ac3 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -3427,14 +3427,6 @@ int bnxt_hwrm_flash_nvram(struct bnxt *bp, uint16_t dir_type, rte_iova_t dma_handle; uint8_t *buf; - HWRM_PREP(req, NVM_WRITE); - - req.dir_type = rte_cpu_to_le_16(dir_type); - req.dir_ordinal = rte_cpu_to_le_16(dir_ordinal); - req.dir_ext = rte_cpu_to_le_16(dir_ext); - req.dir_attr = rte_cpu_to_le_16(dir_attr); - req.dir_data_length = rte_cpu_to_le_32(data_len); - buf = rte_malloc("nvm_write", data_len, 0); rte_mem_lock_page(buf); if (!buf) @@ -3447,6 +3439,14 @@ int bnxt_hwrm_flash_nvram(struct bnxt *bp, uint16_t dir_type, return -ENOMEM; } memcpy(buf, data, data_len); + + HWRM_PREP(req, NVM_WRITE); + + req.dir_type = rte_cpu_to_le_16(dir_type); + req.dir_ordinal = rte_cpu_to_le_16(dir_ordinal); + req.dir_ext = rte_cpu_to_le_16(dir_ext); + req.dir_attr = rte_cpu_to_le_16(dir_attr); + req.dir_data_length = rte_cpu_to_le_32(data_len); req.host_src_addr = rte_cpu_to_le_64(dma_handle); rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); -- 2.15.2 (Apple Git-101.1)