lpm: fix allocation of an existing object
authorPavan Nikhilesh <pbhagavatula@caviumnetworks.com>
Tue, 30 Jan 2018 18:51:54 +0000 (00:21 +0530)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 31 Jan 2018 23:35:06 +0000 (00:35 +0100)
Fix rte_lpm_create_*() functions to return NULL and set rte_errno to
EEXIST when lpm object name already exists.
This is the behavior described in the API documentation in the header
file.

Fixes: 134975073af3 ("lib: remove unnecessary pointer cast")

Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
Acked-by: Phil Yang <phil.yang@arm.com>
Reviewed-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
lib/librte_lpm/rte_lpm.c

index d464dbd..d00b13d 100644 (file)
@@ -180,6 +180,7 @@ rte_lpm_create_v20(const char *name, int socket_id, int max_rules,
        }
 
        if (te != NULL) {
+               lpm = NULL;
                rte_errno = EEXIST;
                goto exit;
        }
@@ -256,6 +257,7 @@ rte_lpm_create_v1604(const char *name, int socket_id,
        }
 
        if (te != NULL) {
+               lpm = NULL;
                rte_errno = EEXIST;
                goto exit;
        }