[dpdk-stable] patch 'net/ice/base: fix memory leak on error path' has been queued to stable release 19.11.4

luca.boccassi at gmail.com luca.boccassi at gmail.com
Fri Jul 24 13:57:54 CEST 2020


Hi,

FYI, your patch has been queued to stable release 19.11.4

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 07/26/20. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Thanks.

Luca Boccassi

---
>From 26c98b7ec335eb0e3e1d0146e798e53f88f36b0d Mon Sep 17 00:00:00 2001
From: Qi Zhang <qi.z.zhang at intel.com>
Date: Mon, 15 Jun 2020 10:04:59 +0800
Subject: [PATCH] net/ice/base: fix memory leak on error path

[ upstream commit be45049b3c4340499dad5648f455f7b443975671 ]

Handles memory leaks during control queue initialization and
buffer allocation failures. The MACRO - ICE_FREE_CQ_BUFS is modified to
re-use for this fix.

Fixes: 6c1f26be50a2 ("net/ice/base: add control queue information")

Signed-off-by: Surabhi Boob <surabhi.boob at intel.com>
Signed-off-by: Paul M Stillwell Jr <paul.m.stillwell.jr at intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang at intel.com>
Acked-by: Qiming Yang <qiming.yang at intel.com>
---
 drivers/net/ice/base/ice_controlq.c | 39 ++++++++++++++++++-----------
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ice/base/ice_controlq.c b/drivers/net/ice/base/ice_controlq.c
index feffb5198..0b651e7db 100644
--- a/drivers/net/ice/base/ice_controlq.c
+++ b/drivers/net/ice/base/ice_controlq.c
@@ -180,7 +180,9 @@ unwind_alloc_rq_bufs:
 	i--;
 	for (; i >= 0; i--)
 		ice_free_dma_mem(hw, &cq->rq.r.rq_bi[i]);
+	cq->rq.r.rq_bi = NULL;
 	ice_free(hw, cq->rq.dma_head);
+	cq->rq.dma_head = NULL;
 
 	return ICE_ERR_NO_MEMORY;
 }
@@ -218,7 +220,9 @@ unwind_alloc_sq_bufs:
 	i--;
 	for (; i >= 0; i--)
 		ice_free_dma_mem(hw, &cq->sq.r.sq_bi[i]);
+	cq->sq.r.sq_bi = NULL;
 	ice_free(hw, cq->sq.dma_head);
+	cq->sq.dma_head = NULL;
 
 	return ICE_ERR_NO_MEMORY;
 }
@@ -277,6 +281,24 @@ ice_cfg_rq_regs(struct ice_hw *hw, struct ice_ctl_q_info *cq)
 	return ICE_SUCCESS;
 }
 
+#define ICE_FREE_CQ_BUFS(hw, qi, ring)					\
+do {									\
+	/* free descriptors */						\
+	if ((qi)->ring.r.ring##_bi) {					\
+		int i;							\
+									\
+		for (i = 0; i < (qi)->num_##ring##_entries; i++)	\
+			if ((qi)->ring.r.ring##_bi[i].pa)		\
+				ice_free_dma_mem((hw),			\
+					&(qi)->ring.r.ring##_bi[i]);	\
+	}								\
+	/* free the buffer info list */					\
+	if ((qi)->ring.cmd_buf)						\
+		ice_free(hw, (qi)->ring.cmd_buf);			\
+	/* free DMA head */						\
+	ice_free(hw, (qi)->ring.dma_head);				\
+} while (0)
+
 /**
  * ice_init_sq - main initialization routine for Control ATQ
  * @hw: pointer to the hardware structure
@@ -332,6 +354,7 @@ static enum ice_status ice_init_sq(struct ice_hw *hw, struct ice_ctl_q_info *cq)
 	goto init_ctrlq_exit;
 
 init_ctrlq_free_rings:
+	ICE_FREE_CQ_BUFS(hw, cq, sq);
 	ice_free_cq_ring(hw, &cq->sq);
 
 init_ctrlq_exit:
@@ -393,27 +416,13 @@ static enum ice_status ice_init_rq(struct ice_hw *hw, struct ice_ctl_q_info *cq)
 	goto init_ctrlq_exit;
 
 init_ctrlq_free_rings:
+	ICE_FREE_CQ_BUFS(hw, cq, rq);
 	ice_free_cq_ring(hw, &cq->rq);
 
 init_ctrlq_exit:
 	return ret_code;
 }
 
-#define ICE_FREE_CQ_BUFS(hw, qi, ring)					\
-do {									\
-	int i;								\
-	/* free descriptors */						\
-	for (i = 0; i < (qi)->num_##ring##_entries; i++)		\
-		if ((qi)->ring.r.ring##_bi[i].pa)			\
-			ice_free_dma_mem((hw),				\
-					 &(qi)->ring.r.ring##_bi[i]);	\
-	/* free the buffer info list */					\
-	if ((qi)->ring.cmd_buf)						\
-		ice_free(hw, (qi)->ring.cmd_buf);			\
-	/* free DMA head */						\
-	ice_free(hw, (qi)->ring.dma_head);				\
-} while (0)
-
 /**
  * ice_shutdown_sq - shutdown the Control ATQ
  * @hw: pointer to the hardware structure
-- 
2.20.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2020-07-24 12:53:50.001747359 +0100
+++ 0036-net-ice-base-fix-memory-leak-on-error-path.patch	2020-07-24 12:53:48.239005565 +0100
@@ -1,14 +1,15 @@
-From be45049b3c4340499dad5648f455f7b443975671 Mon Sep 17 00:00:00 2001
+From 26c98b7ec335eb0e3e1d0146e798e53f88f36b0d Mon Sep 17 00:00:00 2001
 From: Qi Zhang <qi.z.zhang at intel.com>
 Date: Mon, 15 Jun 2020 10:04:59 +0800
 Subject: [PATCH] net/ice/base: fix memory leak on error path
 
+[ upstream commit be45049b3c4340499dad5648f455f7b443975671 ]
+
 Handles memory leaks during control queue initialization and
 buffer allocation failures. The MACRO - ICE_FREE_CQ_BUFS is modified to
 re-use for this fix.
 
 Fixes: 6c1f26be50a2 ("net/ice/base: add control queue information")
-Cc: stable at dpdk.org
 
 Signed-off-by: Surabhi Boob <surabhi.boob at intel.com>
 Signed-off-by: Paul M Stillwell Jr <paul.m.stillwell.jr at intel.com>
@@ -19,10 +20,10 @@
  1 file changed, 24 insertions(+), 15 deletions(-)
 
 diff --git a/drivers/net/ice/base/ice_controlq.c b/drivers/net/ice/base/ice_controlq.c
-index 3ef86fa03..f278ef636 100644
+index feffb5198..0b651e7db 100644
 --- a/drivers/net/ice/base/ice_controlq.c
 +++ b/drivers/net/ice/base/ice_controlq.c
-@@ -182,7 +182,9 @@ unwind_alloc_rq_bufs:
+@@ -180,7 +180,9 @@ unwind_alloc_rq_bufs:
  	i--;
  	for (; i >= 0; i--)
  		ice_free_dma_mem(hw, &cq->rq.r.rq_bi[i]);
@@ -32,7 +33,7 @@
  
  	return ICE_ERR_NO_MEMORY;
  }
-@@ -220,7 +222,9 @@ unwind_alloc_sq_bufs:
+@@ -218,7 +220,9 @@ unwind_alloc_sq_bufs:
  	i--;
  	for (; i >= 0; i--)
  		ice_free_dma_mem(hw, &cq->sq.r.sq_bi[i]);
@@ -42,7 +43,7 @@
  
  	return ICE_ERR_NO_MEMORY;
  }
-@@ -279,6 +283,24 @@ ice_cfg_rq_regs(struct ice_hw *hw, struct ice_ctl_q_info *cq)
+@@ -277,6 +281,24 @@ ice_cfg_rq_regs(struct ice_hw *hw, struct ice_ctl_q_info *cq)
  	return ICE_SUCCESS;
  }
  
@@ -67,7 +68,7 @@
  /**
   * ice_init_sq - main initialization routine for Control ATQ
   * @hw: pointer to the hardware structure
-@@ -334,6 +356,7 @@ static enum ice_status ice_init_sq(struct ice_hw *hw, struct ice_ctl_q_info *cq)
+@@ -332,6 +354,7 @@ static enum ice_status ice_init_sq(struct ice_hw *hw, struct ice_ctl_q_info *cq)
  	goto init_ctrlq_exit;
  
  init_ctrlq_free_rings:
@@ -75,7 +76,7 @@
  	ice_free_cq_ring(hw, &cq->sq);
  
  init_ctrlq_exit:
-@@ -395,27 +418,13 @@ static enum ice_status ice_init_rq(struct ice_hw *hw, struct ice_ctl_q_info *cq)
+@@ -393,27 +416,13 @@ static enum ice_status ice_init_rq(struct ice_hw *hw, struct ice_ctl_q_info *cq)
  	goto init_ctrlq_exit;
  
  init_ctrlq_free_rings:


More information about the stable mailing list