From 237969a30a0d5f503e213365c7e15676e6b9b4e9 Mon Sep 17 00:00:00 2001 From: Tuomas Taipale Date: Thu, 26 Oct 2023 07:04:45 +0000 Subject: [PATCH] validation: dma: fix packet length when using segmented packets When testing DMA transfers with potentially segmented packets, ensure that allocated packet length does not exceed allocated transfer destination memory size. Signed-off-by: Tuomas Taipale Reviewed-by: Matias Elo --- test/validation/api/dma/dma.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test/validation/api/dma/dma.c b/test/validation/api/dma/dma.c index 7129315eff..787f719a7a 100644 --- a/test/validation/api/dma/dma.c +++ b/test/validation/api/dma/dma.c @@ -1108,7 +1108,7 @@ static void test_dma_pkt_segs_to_addr_sync(void) uint8_t *dst; odp_packet_t pkt; uint32_t i, len, num_segs; - uint32_t pkt_len = global.pkt_len; + uint32_t pkt_len = ODPH_MIN(global.pkt_len, global.len); memset(global.dst_addr, 0, global.data_size); @@ -1128,9 +1128,6 @@ static void test_dma_pkt_segs_to_addr_sync(void) CU_ASSERT_FATAL(odp_packet_copy_from_mem(pkt, 0, pkt_len, global.src_addr) == 0); len = pkt_len - OFFSET - TRAILER; - if (len > global.len) - len = global.len; - dst = global.dst_addr + OFFSET; memset(&src_seg, 0, sizeof(odp_dma_seg_t));