[1/1] kni: fix segfault in rte_kni_get

Message ID 20180628225838.22732-1-dg@adax.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series kni: fix segfault in rte_kni_get |

Checks

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

Commit Message

Dan Gora June 28, 2018, 10:58 p.m. UTC
  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@bisdn.de

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

Comments

Thomas Monjalon Aug. 1, 2018, 4:44 p.m. UTC | #1
This patch is missing review.

29/06/2018 00:58, Dan Gora:
> 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@bisdn.de
> 
> Signed-off-by: Dan Gora <dg@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];
>
  
Ferruh Yigit Aug. 9, 2018, 9:44 a.m. UTC | #2
On 6/28/2018 11:58 PM, Dan Gora wrote:
> 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@bisdn.de
> 
> Signed-off-by: Dan Gora <dg@adax.com>

Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
  
Thomas Monjalon Aug. 9, 2018, 9:52 a.m. UTC | #3
09/08/2018 11:44, Ferruh Yigit:
> On 6/28/2018 11:58 PM, Dan Gora wrote:
> > 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@bisdn.de
> > 
> > Signed-off-by: Dan Gora <dg@adax.com>
> 
> Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

Cc: stable@dpdk.org

Applied, thanks
  

Patch

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];