Null value for parameter name will cause segfault for the
strnlen and strcmp functions.

Fixes: 0b33b68d12 ("ethdev: export allocate function")
Fixes: 942661004c ("ethdev: export secondary attach function")
Cc: sta...@dpdk.org

Signed-off-by: Mohammad Abdul Awal <mohammad.abdul.a...@intel.com>
---
 lib/librte_ethdev/rte_ethdev.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 10bdfb37e..26898ed08 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -440,6 +440,11 @@ rte_eth_dev_allocate(const char *name)
        struct rte_eth_dev *eth_dev = NULL;
        size_t name_len;
 
+       if (name == NULL) {
+               RTE_ETHDEV_LOG(ERR, "Null pointer is specified\n");
+               return NULL;
+       }
+
        name_len = strnlen(name, RTE_ETH_NAME_MAX_LEN);
        if (name_len == 0) {
                RTE_ETHDEV_LOG(ERR, "Zero length Ethernet device name\n");
@@ -492,6 +497,11 @@ rte_eth_dev_attach_secondary(const char *name)
        uint16_t i;
        struct rte_eth_dev *eth_dev = NULL;
 
+       if (name == NULL) {
+               RTE_ETHDEV_LOG(ERR, "Null pointer is specified\n");
+               return NULL;
+       }
+
        rte_eth_dev_shared_data_prepare();
 
        /* Synchronize port attachment to primary port creation and release. */
-- 
2.17.1

Reply via email to