From: Pavan Nikhilesh Date: Tue, 30 Jan 2018 18:51:54 +0000 (+0530) Subject: lpm: fix allocation of an existing object X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=fc29c712dd6758877bb10166d9a7866ee1fa6875;p=dpdk.git lpm: fix allocation of an existing object 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 Acked-by: Phil Yang Reviewed-by: Anatoly Burakov Acked-by: Ferruh Yigit --- diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c index d464dbda90..d00b13d931 100644 --- a/lib/librte_lpm/rte_lpm.c +++ b/lib/librte_lpm/rte_lpm.c @@ -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; }