patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Rasesh Mody <rasesh.mody@cavium.com>
To: <dev@dpdk.org>, <ferruh.yigit@intel.com>
Cc: Rasesh Mody <rasesh.mody@cavium.com>, <stable@dpdk.org>,
	<Dept-EngDPDKDev@cavium.com>
Subject: [dpdk-stable] [PATCH v2 02/21] net/qede/base: fix to set pointers to NULL after freeing
Date: Fri, 17 Mar 2017 23:50:16 -0700	[thread overview]
Message-ID: <1489819823-13025-1-git-send-email-rasesh.mody@cavium.com> (raw)
In-Reply-To: <2152c44b-3013-b709-16c0-cdef9c20fce2@intel.com>

Set pointers to NULL after freeing the allocations. Change OSAL_FREE
macro to take care of this and cleanup relevant code.

Fixes: 26ae839d06e9 ("qede: add DCBX support")
Fixes: ec94dbc57362 ("qede: add base driver")

Signed-off-by: Rasesh Mody <rasesh.mody@cavium.com>
---
 drivers/net/qede/base/bcm_osal.h    |    6 +++++-
 drivers/net/qede/base/ecore_cxt.c   |    3 ---
 drivers/net/qede/base/ecore_dev.c   |   10 +---------
 drivers/net/qede/base/ecore_hw.c    |    1 -
 drivers/net/qede/base/ecore_mcp.c   |    1 -
 drivers/net/qede/base/ecore_sriov.c |    2 --
 drivers/net/qede/base/ecore_vf.c    |    1 -
 7 files changed, 6 insertions(+), 18 deletions(-)

diff --git a/drivers/net/qede/base/bcm_osal.h b/drivers/net/qede/base/bcm_osal.h
index a20b318..88246b7 100644
--- a/drivers/net/qede/base/bcm_osal.h
+++ b/drivers/net/qede/base/bcm_osal.h
@@ -90,7 +90,11 @@ typedef int bool;
 #define OSAL_ZALLOC(dev, GFP, size) rte_zmalloc("qede", size, 0)
 #define OSAL_CALLOC(dev, GFP, num, size) rte_calloc("qede", num, size, 0)
 #define OSAL_VALLOC(dev, size) rte_malloc("qede", size, 0)
-#define OSAL_FREE(dev, memory) rte_free((void *)memory)
+#define OSAL_FREE(dev, memory)		  \
+	do {				  \
+		rte_free((void *)memory); \
+		memory = OSAL_NULL;	  \
+	} while (0)
 #define OSAL_VFREE(dev, memory) OSAL_FREE(dev, memory)
 #define OSAL_MEM_ZERO(mem, size) bzero(mem, size)
 #define OSAL_MEMCPY(dst, src, size) rte_memcpy(dst, src, size)
diff --git a/drivers/net/qede/base/ecore_cxt.c b/drivers/net/qede/base/ecore_cxt.c
index 5ea4f5c..b73a6ac 100644
--- a/drivers/net/qede/base/ecore_cxt.c
+++ b/drivers/net/qede/base/ecore_cxt.c
@@ -766,7 +766,6 @@ static void ecore_cxt_src_t2_free(struct ecore_hwfn *p_hwfn)
 					       p_mngr->t2[i].size);
 
 	OSAL_FREE(p_hwfn->p_dev, p_mngr->t2);
-	p_mngr->t2 = OSAL_NULL;
 }
 
 static enum _ecore_status_t ecore_cxt_src_t2_alloc(struct ecore_hwfn *p_hwfn)
@@ -1157,8 +1156,6 @@ void ecore_cxt_mngr_free(struct ecore_hwfn *p_hwfn)
 	ecore_ilt_shadow_free(p_hwfn);
 	OSAL_MUTEX_DEALLOC(&p_hwfn->p_cxt_mngr->mutex);
 	OSAL_FREE(p_hwfn->p_dev, p_hwfn->p_cxt_mngr);
-
-	p_hwfn->p_cxt_mngr = OSAL_NULL;
 }
 
 void ecore_cxt_mngr_setup(struct ecore_hwfn *p_hwfn)
diff --git a/drivers/net/qede/base/ecore_dev.c b/drivers/net/qede/base/ecore_dev.c
index 0518fc7..426ff46 100644
--- a/drivers/net/qede/base/ecore_dev.c
+++ b/drivers/net/qede/base/ecore_dev.c
@@ -136,13 +136,9 @@ static void ecore_qm_info_free(struct ecore_hwfn *p_hwfn)
 	struct ecore_qm_info *qm_info = &p_hwfn->qm_info;
 
 	OSAL_FREE(p_hwfn->p_dev, qm_info->qm_pq_params);
-	qm_info->qm_pq_params = OSAL_NULL;
 	OSAL_FREE(p_hwfn->p_dev, qm_info->qm_vport_params);
-	qm_info->qm_vport_params = OSAL_NULL;
 	OSAL_FREE(p_hwfn->p_dev, qm_info->qm_port_params);
-	qm_info->qm_port_params = OSAL_NULL;
 	OSAL_FREE(p_hwfn->p_dev, qm_info->wfq_data);
-	qm_info->wfq_data = OSAL_NULL;
 }
 
 void ecore_resc_free(struct ecore_dev *p_dev)
@@ -153,7 +149,6 @@ void ecore_resc_free(struct ecore_dev *p_dev)
 		return;
 
 	OSAL_FREE(p_dev, p_dev->fw_data);
-	p_dev->fw_data = OSAL_NULL;
 
 	OSAL_FREE(p_dev, p_dev->reset_stats);
 
@@ -161,9 +156,7 @@ void ecore_resc_free(struct ecore_dev *p_dev)
 		struct ecore_hwfn *p_hwfn = &p_dev->hwfns[i];
 
 		OSAL_FREE(p_dev, p_hwfn->p_tx_cids);
-		p_hwfn->p_tx_cids = OSAL_NULL;
 		OSAL_FREE(p_dev, p_hwfn->p_rx_cids);
-		p_hwfn->p_rx_cids = OSAL_NULL;
 	}
 
 	for_each_hwfn(p_dev, i) {
@@ -668,8 +661,7 @@ enum _ecore_status_t ecore_resc_alloc(struct ecore_dev *p_dev)
 			DP_ERR(p_hwfn, "Cannot allocate 0x%x EQ elements."
 				       "The maximum of a u16 chain is 0x%x\n",
 			       n_eqes, 0xFFFF);
-			rc = ECORE_INVAL;
-			goto alloc_err;
+			goto alloc_no_mem;
 		}
 
 		p_eq = ecore_eq_alloc(p_hwfn, (u16)n_eqes);
diff --git a/drivers/net/qede/base/ecore_hw.c b/drivers/net/qede/base/ecore_hw.c
index 22da415..49d52c0 100644
--- a/drivers/net/qede/base/ecore_hw.c
+++ b/drivers/net/qede/base/ecore_hw.c
@@ -86,7 +86,6 @@ void ecore_ptt_pool_free(struct ecore_hwfn *p_hwfn)
 	if (p_hwfn->p_ptt_pool)
 		OSAL_SPIN_LOCK_DEALLOC(&p_hwfn->p_ptt_pool->lock);
 	OSAL_FREE(p_hwfn->p_dev, p_hwfn->p_ptt_pool);
-	p_hwfn->p_ptt_pool = OSAL_NULL;
 }
 
 struct ecore_ptt *ecore_ptt_acquire(struct ecore_hwfn *p_hwfn)
diff --git a/drivers/net/qede/base/ecore_mcp.c b/drivers/net/qede/base/ecore_mcp.c
index f634d98..4863ff9 100644
--- a/drivers/net/qede/base/ecore_mcp.c
+++ b/drivers/net/qede/base/ecore_mcp.c
@@ -104,7 +104,6 @@ enum _ecore_status_t ecore_mcp_free(struct ecore_hwfn *p_hwfn)
 		OSAL_SPIN_LOCK_DEALLOC(&p_hwfn->mcp_info->lock);
 	}
 	OSAL_FREE(p_hwfn->p_dev, p_hwfn->mcp_info);
-	p_hwfn->mcp_info = OSAL_NULL;
 
 	return ECORE_SUCCESS;
 }
diff --git a/drivers/net/qede/base/ecore_sriov.c b/drivers/net/qede/base/ecore_sriov.c
index 4c1a078..d28946e 100644
--- a/drivers/net/qede/base/ecore_sriov.c
+++ b/drivers/net/qede/base/ecore_sriov.c
@@ -554,7 +554,6 @@ void ecore_iov_free(struct ecore_hwfn *p_hwfn)
 void ecore_iov_free_hw_info(struct ecore_dev *p_dev)
 {
 	OSAL_FREE(p_dev, p_dev->p_iov_info);
-	p_dev->p_iov_info = OSAL_NULL;
 }
 
 enum _ecore_status_t ecore_iov_hw_info(struct ecore_hwfn *p_hwfn)
@@ -597,7 +596,6 @@ enum _ecore_status_t ecore_iov_hw_info(struct ecore_hwfn *p_hwfn)
 		DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
 			   "IOV capabilities, but no VFs are published\n");
 		OSAL_FREE(p_dev, p_dev->p_iov_info);
-		p_dev->p_iov_info = OSAL_NULL;
 		return ECORE_SUCCESS;
 	}
 
diff --git a/drivers/net/qede/base/ecore_vf.c b/drivers/net/qede/base/ecore_vf.c
index 17ba4d1..0779e11 100644
--- a/drivers/net/qede/base/ecore_vf.c
+++ b/drivers/net/qede/base/ecore_vf.c
@@ -1142,7 +1142,6 @@ enum _ecore_status_t ecore_vf_pf_release(struct ecore_hwfn *p_hwfn)
 	}
 
 	OSAL_FREE(p_hwfn->p_dev, p_hwfn->vf_iov_info);
-	p_hwfn->vf_iov_info = OSAL_NULL;
 
 	return rc;
 }
-- 
1.7.10.3

  parent reply	other threads:[~2017-03-18  6:52 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1488181923-9649-1-git-send-email-rasesh.mody@cavium.com>
2017-03-02 13:04 ` [dpdk-stable] [dpdk-dev] [PATCH 01/21] net/qede/base: fix incorrect typecasting of flag Ferruh Yigit
2017-03-06 20:02   ` Mody, Rasesh
2017-03-18  6:48   ` [dpdk-stable] [PATCH v2 " Rasesh Mody
2017-03-20 17:15     ` Ferruh Yigit
2017-03-18  6:50   ` Rasesh Mody [this message]
2017-03-18  6:50   ` [dpdk-stable] [PATCH v2 03/21] net/qede/base: fix forcing driver default resc allocation Rasesh Mody
2017-03-18  6:50   ` [dpdk-stable] [PATCH v2 04/21] net/qede/base: fix TM block ILT initialization Rasesh Mody
2017-03-18  6:50   ` [dpdk-stable] [PATCH v2 05/21] net/qede/base: fix printout Rasesh Mody
2017-03-18  6:50   ` [dpdk-stable] [PATCH v2 06/21] net/qede/base: fix VF init after malicious VF FLR Rasesh Mody
2017-03-18  6:50   ` [dpdk-stable] [PATCH v2 07/21] net/qede/base: fix numbering L2 VF queues Rasesh Mody
2017-03-18  6:50   ` [dpdk-stable] [PATCH v2 08/21] net/qede/base: fix index printing of multi-bit attentions Rasesh Mody
2017-03-18  6:50   ` [dpdk-stable] [PATCH v2 09/21] net/qede/base: fix to prevent VF promisc config Rasesh Mody
2017-03-18  6:53   ` [dpdk-stable] [PATCH v2 10/21] net/qede/base: add attention bits for AH chip Rasesh Mody
2017-03-18  6:53   ` [dpdk-stable] [PATCH v2 11/21] net/qede/base: fix printout Rasesh Mody
2017-03-18  6:53   ` [dpdk-stable] [PATCH v2 12/21] net/qede/base: fix DORQ attention mask Rasesh Mody
2017-03-18  6:53   ` [dpdk-stable] [PATCH v2 13/21] net/qede/base: fix out-of-bound memory access Rasesh Mody
2017-03-18  6:53   ` [dpdk-stable] [PATCH v2 14/21] net/qede/base: fix to remove redundant memset Rasesh Mody
2017-03-18  6:53   ` [dpdk-stable] [PATCH v2 15/21] net/qede/base: fix remove the unneeded conversion to LE Rasesh Mody
2017-03-18  6:53   ` [dpdk-stable] [PATCH v2 16/21] net/qede/base: fix first VF index calculation Rasesh Mody
2017-03-18  6:53   ` [dpdk-stable] [PATCH v2 17/21] net/qede/base: fix typo Rasesh Mody
2017-03-18  6:53   ` [dpdk-stable] [PATCH v2 18/21] net/qede/base: refactor return path Rasesh Mody
2017-03-18  6:53   ` [dpdk-stable] [PATCH v2 19/21] net/qede/base: fix sriov typo Rasesh Mody
2017-03-18  6:57   ` [dpdk-stable] [PATCH v2 20/21] net/qede/base: fix resource lock minimum value Rasesh Mody
2017-03-18  6:57   ` [dpdk-stable] [PATCH v2 21/21] net/qede/base: fix to use NULL pointer Rasesh Mody

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=1489819823-13025-1-git-send-email-rasesh.mody@cavium.com \
    --to=rasesh.mody@cavium.com \
    --cc=Dept-EngDPDKDev@cavium.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.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).