drivers/crypto: check if name is null
authorPablo de Lara <pablo.de.lara.guarch@intel.com>
Tue, 18 Apr 2017 14:34:19 +0000 (15:34 +0100)
committerPablo de Lara <pablo.de.lara.guarch@intel.com>
Thu, 20 Apr 2017 09:32:45 +0000 (11:32 +0200)
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 <pablo.de.lara.guarch@intel.com>
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
drivers/crypto/armv8/rte_armv8_pmd.c
drivers/crypto/kasumi/rte_kasumi_pmd.c
drivers/crypto/null/null_crypto_pmd.c
drivers/crypto/openssl/rte_openssl_pmd.c
drivers/crypto/scheduler/scheduler_pmd.c
drivers/crypto/snow3g/rte_snow3g_pmd.c
drivers/crypto/zuc/rte_zuc_pmd.c

index 1705896..f4dd1ae 100644 (file)
@@ -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);
 
index 37b22ec..88b691e 100644 (file)
@@ -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);
 
index bf56bc6..a8af4a3 100644 (file)
@@ -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);
 
index 42fdd33..b4476e8 100644 (file)
@@ -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);
index a44c61a..3d131ca 100644 (file)
@@ -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);
index f3c8f83..9deead8 100644 (file)
@@ -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);
index 2a92d1e..c03f1ca 100644 (file)
@@ -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);
index a31eaa8..42b802b 100644 (file)
@@ -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);
index 5eec933..22bf8bf 100644 (file)
@@ -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);