hash: fix allocation of an existing object
[dpdk.git] / lib / librte_hash / rte_cuckoo_hash.c
index 04e95b7..b00cc12 100644 (file)
@@ -299,8 +299,10 @@ rte_hash_create(const struct rte_hash_parameters *params)
 
        /* Guarantee there's no existing */
        h = rte_hash_find_existing(params->name);
-       if (h != NULL)
-               return h;
+       if (h != NULL) {
+               rte_errno = EEXIST;
+               return NULL;
+       }
 
        te = rte_zmalloc("HASH_TAILQ_ENTRY", sizeof(*te), 0);
        if (te == NULL) {