From 7e21477118bb9b0150d068dff3f0f52966c0ccda Mon Sep 17 00:00:00 2001 From: Pablo de Lara Date: Tue, 18 Apr 2017 15:34:19 +0100 Subject: [PATCH] drivers/crypto: check if name is null Check if virtual device name is NULL, to avoid possible segmentation faults. Fixes: 5d2aa461cbca ("vdev: use generic vdev struct for probe and remove") Signed-off-by: Pablo de Lara Acked-by: Fan Zhang --- drivers/crypto/aesni_gcm/aesni_gcm_pmd.c | 2 ++ drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c | 2 ++ drivers/crypto/armv8/rte_armv8_pmd.c | 2 ++ drivers/crypto/kasumi/rte_kasumi_pmd.c | 2 ++ drivers/crypto/null/null_crypto_pmd.c | 8 +++++--- drivers/crypto/openssl/rte_openssl_pmd.c | 2 ++ drivers/crypto/scheduler/scheduler_pmd.c | 7 ++++++- drivers/crypto/snow3g/rte_snow3g_pmd.c | 2 ++ drivers/crypto/zuc/rte_zuc_pmd.c | 2 ++ 9 files changed, 25 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c index 1705896f0b..f4dd1ae0b9 100644 --- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c +++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c @@ -501,6 +501,8 @@ aesni_gcm_probe(struct rte_vdev_device *vdev) const char *input_args; name = rte_vdev_device_name(vdev); + if (name == NULL) + return -EINVAL; input_args = rte_vdev_device_args(vdev); rte_cryptodev_parse_vdev_init_params(&init_params, input_args); diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c index 37b22ec69f..88b691e8ff 100644 --- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c +++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c @@ -768,6 +768,8 @@ cryptodev_aesni_mb_probe(struct rte_vdev_device *vdev) const char *input_args; name = rte_vdev_device_name(vdev); + if (name == NULL) + return -EINVAL; input_args = rte_vdev_device_args(vdev); rte_cryptodev_parse_vdev_init_params(&init_params, input_args); diff --git a/drivers/crypto/armv8/rte_armv8_pmd.c b/drivers/crypto/armv8/rte_armv8_pmd.c index bf56bc62a4..a8af4a3dfb 100644 --- a/drivers/crypto/armv8/rte_armv8_pmd.c +++ b/drivers/crypto/armv8/rte_armv8_pmd.c @@ -864,6 +864,8 @@ cryptodev_armv8_crypto_init(struct rte_vdev_device *vdev) const char *input_args; name = rte_vdev_device_name(vdev); + if (name == NULL) + return -EINVAL; input_args = rte_vdev_device_args(vdev); rte_cryptodev_parse_vdev_init_params(&init_params, input_args); diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd.c b/drivers/crypto/kasumi/rte_kasumi_pmd.c index 42fdd33a7c..b4476e8881 100644 --- a/drivers/crypto/kasumi/rte_kasumi_pmd.c +++ b/drivers/crypto/kasumi/rte_kasumi_pmd.c @@ -624,6 +624,8 @@ cryptodev_kasumi_probe(struct rte_vdev_device *vdev) const char *input_args; name = rte_vdev_device_name(vdev); + if (name == NULL) + return -EINVAL; input_args = rte_vdev_device_args(vdev); rte_cryptodev_parse_vdev_init_params(&init_params, input_args); diff --git a/drivers/crypto/null/null_crypto_pmd.c b/drivers/crypto/null/null_crypto_pmd.c index a44c61a446..3d131cae17 100644 --- a/drivers/crypto/null/null_crypto_pmd.c +++ b/drivers/crypto/null/null_crypto_pmd.c @@ -226,12 +226,14 @@ cryptodev_null_probe(struct rte_vdev_device *dev) rte_socket_id(), {0} }; + const char *name; - rte_cryptodev_parse_vdev_init_params(&init_params, - rte_vdev_device_args(dev)); + name = rte_vdev_device_name(dev); + if (name == NULL) + return -EINVAL; RTE_LOG(INFO, PMD, "Initialising %s on NUMA node %d\n", - rte_vdev_device_name(dev), init_params.socket_id); + name, init_params.socket_id); if (init_params.name[0] != '\0') RTE_LOG(INFO, PMD, " User defined name = %s\n", init_params.name); diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c index f3c8f839d9..9deead8efd 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd.c +++ b/drivers/crypto/openssl/rte_openssl_pmd.c @@ -1331,6 +1331,8 @@ cryptodev_openssl_probe(struct rte_vdev_device *vdev) const char *input_args; name = rte_vdev_device_name(vdev); + if (name == NULL) + return -EINVAL; input_args = rte_vdev_device_args(vdev); rte_cryptodev_parse_vdev_init_params(&init_params, input_args); diff --git a/drivers/crypto/scheduler/scheduler_pmd.c b/drivers/crypto/scheduler/scheduler_pmd.c index 2a92d1e9a8..c03f1ca162 100644 --- a/drivers/crypto/scheduler/scheduler_pmd.c +++ b/drivers/crypto/scheduler/scheduler_pmd.c @@ -414,12 +414,17 @@ cryptodev_scheduler_probe(struct rte_vdev_device *vdev) .enable_ordering = 0, .slave_names = { {0} } }; + const char *name; + + name = rte_vdev_device_name(vdev); + if (name == NULL) + return -EINVAL; scheduler_parse_init_params(&init_params, rte_vdev_device_args(vdev)); RTE_LOG(INFO, PMD, "Initialising %s on NUMA node %d\n", - rte_vdev_device_name(vdev), + name, init_params.def_p.socket_id); RTE_LOG(INFO, PMD, " Max number of queue pairs = %d\n", init_params.def_p.max_nb_queue_pairs); diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c index a31eaa81b0..42b802bcde 100644 --- a/drivers/crypto/snow3g/rte_snow3g_pmd.c +++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c @@ -613,6 +613,8 @@ cryptodev_snow3g_probe(struct rte_vdev_device *vdev) const char *input_args; name = rte_vdev_device_name(vdev); + if (name == NULL) + return -EINVAL; input_args = rte_vdev_device_args(vdev); rte_cryptodev_parse_vdev_init_params(&init_params, input_args); diff --git a/drivers/crypto/zuc/rte_zuc_pmd.c b/drivers/crypto/zuc/rte_zuc_pmd.c index 5eec9334bd..22bf8bf583 100644 --- a/drivers/crypto/zuc/rte_zuc_pmd.c +++ b/drivers/crypto/zuc/rte_zuc_pmd.c @@ -513,6 +513,8 @@ cryptodev_zuc_probe(struct rte_vdev_device *vdev) const char *input_args; name = rte_vdev_device_name(vdev); + if (name == NULL) + return -EINVAL; input_args = rte_vdev_device_args(vdev); rte_cryptodev_parse_vdev_init_params(&init_params, input_args); -- 2.20.1