[dpdk-dev,v1] lib/distributor: fix segfaults in flush

Message ID 1492072587-121343-1-git-send-email-david.hunt@intel.com (mailing list archive)
State Superseded, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Hunt, David April 13, 2017, 8:36 a.m. UTC
  A segfault when flushing packets has been revealed by further testing
when using distributor in single packet mode. This patch resolves that.

Fixes: 775003ad2f96 ("distributor: add new burst-capable library")

Reported-by: Yong Liu <yong.liu@intel.com>
Signed-off-by: David Hunt <david.hunt@intel.com>
---
 lib/librte_distributor/rte_distributor.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
  

Comments

Marvin Liu April 14, 2017, 6:04 a.m. UTC | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of David Hunt
> Sent: Thursday, April 13, 2017 4:36 PM
> To: dev@dpdk.org
> Cc: Hunt, David <david.hunt@intel.com>
> Subject: [dpdk-dev] [PATCH v1] lib/distributor: fix segfaults in flush
> 
> A segfault when flushing packets has been revealed by further testing
> when using distributor in single packet mode. This patch resolves that.
> 
> Fixes: 775003ad2f96 ("distributor: add new burst-capable library")
> 
> Reported-by: Yong Liu <yong.liu@intel.com>
> Signed-off-by: David Hunt <david.hunt@intel.com>
> ---

Tested-by: Yong Liu <yong.liu@intel.com>
  
Bruce Richardson April 14, 2017, 8:41 a.m. UTC | #2
On Thu, Apr 13, 2017 at 09:36:27AM +0100, David Hunt wrote:
> A segfault when flushing packets has been revealed by further testing
> when using distributor in single packet mode. This patch resolves that.
> 
> Fixes: 775003ad2f96 ("distributor: add new burst-capable library")
> 
> Reported-by: Yong Liu <yong.liu@intel.com>
> Signed-off-by: David Hunt <david.hunt@intel.com>

Hi Dave,

I think you could do with giving more details in the commit messaage on
how/why the error occurs and how exactly this patch fixes it.

With expanded commit log message:
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
  

Patch

diff --git a/lib/librte_distributor/rte_distributor.c b/lib/librte_distributor/rte_distributor.c
index 4725904..e4dfa7f 100644
--- a/lib/librte_distributor/rte_distributor.c
+++ b/lib/librte_distributor/rte_distributor.c
@@ -555,7 +555,7 @@  total_outstanding(const struct rte_distributor *d)
 int
 rte_distributor_flush_v1705(struct rte_distributor *d)
 {
-	const unsigned int flushed = total_outstanding(d);
+	unsigned int flushed;
 	unsigned int wkr;
 
 	if (d->alg_type == RTE_DIST_ALG_SINGLE) {
@@ -563,6 +563,8 @@  rte_distributor_flush_v1705(struct rte_distributor *d)
 		return rte_distributor_flush_v20(d->d_v20);
 	}
 
+	flushed = total_outstanding(d);
+
 	while (total_outstanding(d) > 0)
 		rte_distributor_process(d, NULL, 0);
 
@@ -590,6 +592,7 @@  rte_distributor_clear_returns_v1705(struct rte_distributor *d)
 	if (d->alg_type == RTE_DIST_ALG_SINGLE) {
 		/* Call the old API */
 		rte_distributor_clear_returns_v20(d->d_v20);
+		return;
 	}
 
 	/* throw away returns, so workers can exit */