[dpdk-dev] [PATCH 1/1] kni: fix segfault in rte_kni_get

Dan Gora dg at adax.com
Fri Jun 29 00:58:38 CEST 2018


Fix a segmentation fault which occurs when the kni_autotest is run
in the 'test' application.

This segmenation fault occurs when rte_kni_get() is called with a
NULL value for 'name'.

Fixes: 0c6bc8ef70ba ("kni: memzone pool for alloc and release")
Cc: marc.sune at bisdn.de

Signed-off-by: Dan Gora <dg at adax.com>
---
 lib/librte_kni/rte_kni.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
index aa3559306..c4199e6ab 100644
--- a/lib/librte_kni/rte_kni.c
+++ b/lib/librte_kni/rte_kni.c
@@ -744,6 +744,9 @@ rte_kni_get(const char *name)
 	struct rte_kni_memzone_slot *it;
 	struct rte_kni *kni;
 
+	if (name == NULL || name[0] == '\0')
+		return NULL;
+
 	/* Note: could be improved perf-wise if necessary */
 	for (i = 0; i < kni_memzone_pool.max_ifaces; i++) {
 		it = &kni_memzone_pool.slots[i];
-- 
2.18.0.rc1.1.g6f333ff2f



More information about the dev mailing list