mem: fix possible integer overflow
[dpdk.git] / lib / librte_lpm / rte_lpm6.c
index 4c44cd7..32fdba0 100644 (file)
@@ -182,8 +182,11 @@ rte_lpm6_create(const char *name, int socket_id,
                if (strncmp(name, lpm->name, RTE_LPM6_NAMESIZE) == 0)
                        break;
        }
-       if (te != NULL)
+       lpm = NULL;
+       if (te != NULL) {
+               rte_errno = EEXIST;
                goto exit;
+       }
 
        /* allocate tailq entry */
        te = rte_zmalloc("LPM6_TAILQ_ENTRY", sizeof(*te), 0);
@@ -598,7 +601,7 @@ int
 rte_lpm6_lookup(const struct rte_lpm6 *lpm, uint8_t *ip, uint8_t *next_hop)
 {
        const struct rte_lpm6_tbl_entry *tbl;
-       const struct rte_lpm6_tbl_entry *tbl_next;
+       const struct rte_lpm6_tbl_entry *tbl_next = NULL;
        int status;
        uint8_t first_byte;
        uint32_t tbl24_index;
@@ -633,7 +636,7 @@ rte_lpm6_lookup_bulk_func(const struct rte_lpm6 *lpm,
 {
        unsigned i;
        const struct rte_lpm6_tbl_entry *tbl;
-       const struct rte_lpm6_tbl_entry *tbl_next;
+       const struct rte_lpm6_tbl_entry *tbl_next = NULL;
        uint32_t tbl24_index;
        uint8_t first_byte, next_hop;
        int status;