[dpdk-dev] lib/lpm: fix return value of rte_lpm_create

Message ID 4bc7c2df8284aa94d37cbb8f80b7f952dd03d6f8.1517401724.git.anatoly.burakov@intel.com (mailing list archive)
State Superseded, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Anatoly Burakov Jan. 31, 2018, 12:40 p.m. UTC
  LPM library is supposed to return NULL pointer on an attempt
to call rte_lpm_create with an existing name.

Fixes: 134975073af3 ("lib: remove unnecessary pointer cast")
Cc: zhiyong.yang@intel.com

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_lpm/rte_lpm.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Bruce Richardson Jan. 31, 2018, 1:11 p.m. UTC | #1
On Wed, Jan 31, 2018 at 12:40:59PM +0000, Anatoly Burakov wrote:
> LPM library is supposed to return NULL pointer on an attempt
> to call rte_lpm_create with an existing name.
> 
> Fixes: 134975073af3 ("lib: remove unnecessary pointer cast")
> Cc: zhiyong.yang@intel.com
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---

This looks a duplicate of http://dpdk.org/dev/patchwork/patch/34739/, is
that correct?
If so, please review/test/ack that patch to confirm it fixes the issues
you see too.

Thanks,
/Bruce
  
Anatoly Burakov Jan. 31, 2018, 1:29 p.m. UTC | #2
On 31-Jan-18 1:11 PM, Bruce Richardson wrote:
> On Wed, Jan 31, 2018 at 12:40:59PM +0000, Anatoly Burakov wrote:
>> LPM library is supposed to return NULL pointer on an attempt
>> to call rte_lpm_create with an existing name.
>>
>> Fixes: 134975073af3 ("lib: remove unnecessary pointer cast")
>> Cc: zhiyong.yang@intel.com
>>
>> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
>> ---
> 
> This looks a duplicate of http://dpdk.org/dev/patchwork/patch/34739/, is
> that correct?
> If so, please review/test/ack that patch to confirm it fixes the issues
> you see too.
> 
> Thanks,
> /Bruce
> 
You're correct, missed that. Thanks!
  

Patch

diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c
index d464dbd..efbbbca 100644
--- a/lib/librte_lpm/rte_lpm.c
+++ b/lib/librte_lpm/rte_lpm.c
@@ -254,6 +254,7 @@  rte_lpm_create_v1604(const char *name, int socket_id,
 		if (strncmp(name, lpm->name, RTE_LPM_NAMESIZE) == 0)
 			break;
 	}
+	lpm = NULL;
 
 	if (te != NULL) {
 		rte_errno = EEXIST;