mempool: fix leak when no objects are populated
authorAndrew Rybchenko <arybchenko@solarflare.com>
Mon, 16 Apr 2018 13:24:30 +0000 (14:24 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 23 Apr 2018 23:28:53 +0000 (01:28 +0200)
Fixes: 84121f197187 ("mempool: store memory chunks in a list")
Cc: stable@dpdk.org
Suggested-by: Olivier Matz <olivier.matz@6wind.com>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
lib/librte_mempool/rte_mempool.c

index 103c015..3b31a55 100644 (file)
@@ -421,12 +421,18 @@ rte_mempool_populate_iova(struct rte_mempool *mp, char *vaddr,
        }
 
        /* not enough room to store one object */
-       if (i == 0)
-               return -EINVAL;
+       if (i == 0) {
+               ret = -EINVAL;
+               goto fail;
+       }
 
        STAILQ_INSERT_TAIL(&mp->mem_list, memhdr, next);
        mp->nb_mem_chunks++;
        return i;
+
+fail:
+       rte_free(memhdr);
+       return ret;
 }
 
 int