From 265431ba12dd31870c0762e83b08d9be9039bed0 Mon Sep 17 00:00:00 2001 From: Suanming Mou Date: Wed, 3 Jan 2024 11:53:57 +0800 Subject: [PATCH] app/test-crypto-perf: fix invalid mbuf next operation In fill_multi_seg_mbuf(), when remaining_segments is 0, rte_mbuf m's next should pointer to NULL instead of a new rte_mbuf, that casues setting m->next as NULL out of the while loop to the invalid mbuf. This commit fixes the invalid mbuf next operation. Fixes: bf9d6702eca9 ("app/crypto-perf: use single mempool") Signed-off-by: Suanming Mou Signed-off-by: 0-day Robot --- app/test-crypto-perf/cperf_test_common.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/test-crypto-perf/cperf_test_common.c b/app/test-crypto-perf/cperf_test_common.c index 932aab16df5..ad2076dd2ea 100644 --- a/app/test-crypto-perf/cperf_test_common.c +++ b/app/test-crypto-perf/cperf_test_common.c @@ -72,13 +72,15 @@ fill_multi_seg_mbuf(struct rte_mbuf *m, struct rte_mempool *mp, rte_mbuf_refcnt_set(m, 1); next_mbuf = (struct rte_mbuf *) ((uint8_t *) m + mbuf_hdr_size + segment_sz); - m->next = next_mbuf; - m = next_mbuf; - remaining_segments--; + remaining_segments--; + if (remaining_segments > 0) { + m->next = next_mbuf; + m = next_mbuf; + } else { + m->next = NULL; + } } while (remaining_segments > 0); - - m->next = NULL; } static void