summaryrefslogtreecommitdiffstats
path: root/VNFs
diff options
context:
space:
mode:
authorDeepak S <deepak.s@linux.intel.com>2018-10-31 17:44:59 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-10-31 17:44:59 +0000
commit6d005f74525630cd63a759bff8cf2e9ae6b02e88 (patch)
treed06c2f72fc9a321a6bbb53fe66d1699f28397f26 /VNFs
parent997a3664e7508f5e2b24cb0d105e411bf71e0d60 (diff)
parent7a15b2e3e49cce7c8cfd1d0a03ee5cf82676bdcb (diff)
Merge "Fix potential crash when shuffling mbufs"
Diffstat (limited to 'VNFs')
-rw-r--r--VNFs/DPPD-PROX/main.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/VNFs/DPPD-PROX/main.c b/VNFs/DPPD-PROX/main.c
index 96272fe3..499a1ab7 100644
--- a/VNFs/DPPD-PROX/main.c
+++ b/VNFs/DPPD-PROX/main.c
@@ -624,13 +624,14 @@ static void shuffle_mempool(struct rte_mempool* mempool, uint32_t nb_mbuf)
struct rte_mbuf** pkts = prox_zmalloc(nb_mbuf * sizeof(*pkts), rte_socket_id());
uint64_t got = 0;
- while (rte_mempool_get_bulk(mempool, (void**)(pkts + got), 1) == 0)
+ while ((got < nb_mbuf) && (rte_mempool_get_bulk(mempool, (void**)(pkts + got), 1) == 0))
++got;
+ nb_mbuf = got;
while (got) {
int idx;
do {
- idx = rand() % nb_mbuf - 1;
+ idx = rand() % nb_mbuf;
} while (pkts[idx] == 0);
rte_mempool_put_bulk(mempool, (void**)&pkts[idx], 1);