[dpdk-dev] cryptodev: fix crash on null dereference

Message ID 1479237103-7166-1-git-send-email-jerin.jacob@caviumnetworks.com (mailing list archive)
State Superseded, archived
Delegated to: Pablo de Lara Guarch
Headers

Checks

Context Check Description
checkpatch/checkpatch success coding style OK

Commit Message

Jerin Jacob Nov. 15, 2016, 7:11 p.m. UTC
  crypodev->data->name will be null when
rte_cryptodev_get_dev_id() invoked without a valid
crypto device instance.

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
 lib/librte_cryptodev/rte_cryptodev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
  

Comments

Arkadiusz Kusztal Nov. 16, 2016, 12:11 p.m. UTC | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jerin Jacob
> Sent: Tuesday, November 15, 2016 7:12 PM
> To: dev@dpdk.org
> Cc: Doherty, Declan <declan.doherty@intel.com>; Jerin Jacob
> <jerin.jacob@caviumnetworks.com>
> Subject: [dpdk-dev] [PATCH] cryptodev: fix crash on null dereference
> 
> crypodev->data->name will be null when
> rte_cryptodev_get_dev_id() invoked without a valid crypto device instance.
> 
> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> ---
>  lib/librte_cryptodev/rte_cryptodev.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> --
> 2.5.5
Acked-by: Arek Kusztal <arkadiuszx.kusztal@intel.com>
  
De Lara Guarch, Pablo Nov. 30, 2016, 3:10 p.m. UTC | #2
Hi Jerin,

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jerin Jacob
> Sent: Tuesday, November 15, 2016 7:12 PM
> To: dev@dpdk.org
> Cc: Doherty, Declan; Jerin Jacob
> Subject: [dpdk-dev] [PATCH] cryptodev: fix crash on null dereference
> 
> crypodev->data->name will be null when
> rte_cryptodev_get_dev_id() invoked without a valid
> crypto device instance.
> 
> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>

Could you add a "Fixes" line? 

Thanks,
Pablo
  
Jerin Jacob Nov. 30, 2016, 8:36 p.m. UTC | #3
On Wed, Nov 30, 2016 at 03:10:14PM +0000, De Lara Guarch, Pablo wrote:
> Hi Jerin,
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jerin Jacob
> > Sent: Tuesday, November 15, 2016 7:12 PM
> > To: dev@dpdk.org
> > Cc: Doherty, Declan; Jerin Jacob
> > Subject: [dpdk-dev] [PATCH] cryptodev: fix crash on null dereference
> > 
> > crypodev->data->name will be null when
> > rte_cryptodev_get_dev_id() invoked without a valid
> > crypto device instance.
> > 
> > Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> 
> Could you add a "Fixes" line? 

Sure. I will send the v2 then

> 
> Thanks,
> Pablo
  

Patch

diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index 127e8d0..54e95d5 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -225,13 +225,14 @@  rte_cryptodev_create_vdev(const char *name, const char *args)
 }
 
 int
-rte_cryptodev_get_dev_id(const char *name) {
+rte_cryptodev_get_dev_id(const char *name)
+{
 	unsigned i;
 
 	if (name == NULL)
 		return -1;
 
-	for (i = 0; i < rte_cryptodev_globals->max_devs; i++)
+	for (i = 0; i < rte_cryptodev_globals->nb_devs; i++)
 		if ((strcmp(rte_cryptodev_globals->devs[i].data->name, name)
 				== 0) &&
 				(rte_cryptodev_globals->devs[i].attached ==