Skip to contentSkip to conversation

kni: fix segfault in rte_kni_get

PATCH Applied Dan Gora 3 participants 4 messages Jun 28, 2018 – Aug 9, 2018

lore
Share & tools
lore

Dan Gora

author
#0 lore raw

PATCH 1/1 kni: fix segfault in rte_kni_get

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")
---
 lib/librte_kni/rte_kni.c | 3 +++
 1 file changed, 3 insertions(+)
lib/librte_kni/rte_kni.c +3 -0
index aa3559306..c4199e6ab 100644
@@ -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];
Signature · 1 line
2.18.0.rc1.1.g6f333ff2f
#1 lore raw

This patch is missing review.

29/06/2018 00:58, Dan Gora:

Quoted 29 lines

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")
---
 lib/librte_kni/rte_kni.c | 3 +++
 1 file changed, 3 insertions(+)
lib/librte_kni/rte_kni.c +3 -0
index aa3559306..c4199e6ab 100644
@@ -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];
#3 lore raw

09/08/2018 11:44, Ferruh Yigit:

Quoted 7 lines · Dan Gora
Quoted 6 lines

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'.

Quoted 6 lines
Quoted 4 lines
Fixes 0c6bc8ef70ba ("kni: memzone pool for alloc and release")

Applied, thanks