summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerin Jacob <jerin.jacob@caviumnetworks.com>2016-12-04 00:04:01 +0530
committerPablo de Lara <pablo.de.lara.guarch@intel.com>2017-01-18 21:45:15 +0100
commit53a3ba0c36757cd74bc8411e60aa81c91f679cd3 (patch)
tree2c59d698d6f054b95220ce47fe317e900ad38359
parentaa8128b1d830dbfcd92636a5fb6038a3b877ffc1 (diff)
downloaddpdk-53a3ba0c36757cd74bc8411e60aa81c91f679cd3.zip
dpdk-53a3ba0c36757cd74bc8411e60aa81c91f679cd3.tar.gz
dpdk-53a3ba0c36757cd74bc8411e60aa81c91f679cd3.tar.xz
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. Fixes: d11b0f30df88 ("cryptodev: introduce API and framework for crypto devices") Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com> Acked-by: Arek Kusztal <arkadiuszx.kusztal@intel.com>
-rw-r--r--lib/librte_cryptodev/rte_cryptodev.c5
1 files changed, 3 insertions, 2 deletions
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 ==