From: Zongyu Wu <wuzongyu1@huawei.com> When the input block size is smaller than the minimum limit, it may cause reading from an invalid memory address, leading to a segmentation fault. An additional check should be added to prevent the block size from being less than the minimum allowed value. Upstream: Yes AR: AR20230706877877 DTS:DTS2025112007924 Feature or Bugfix: Bugfix Signed-off-by: Zongyu Wu <wuzongyu1@huawei.com> --- uadk_tool/benchmark/zip_wd_benchmark.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/uadk_tool/benchmark/zip_wd_benchmark.c b/uadk_tool/benchmark/zip_wd_benchmark.c index 8388fd0..8b66da1 100644 --- a/uadk_tool/benchmark/zip_wd_benchmark.c +++ b/uadk_tool/benchmark/zip_wd_benchmark.c @@ -22,6 +22,8 @@ #define CHUNK_SIZE (128 * 1024) #define MAX_UNRECV_PACKET_NUM 2 #define MAX_POOL_CREATE_FAIL_TIME 10 +#define MIN_CTX_BUF_SIZE 65536 +#define STREAM_MODE_TYPE 2 #define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask)) #define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a)-1) @@ -323,6 +325,10 @@ static int init_zip_wd_queue(struct acc_option *options) else outsize = g_pktlen * DECOMP_LEN_RATE; + /* Stream mode block size should bigger than 64K */ + if (options->optype >= STREAM_MODE_TYPE && outsize < MIN_CTX_BUF_SIZE) + outsize = MIN_CTX_BUF_SIZE; + g_thread_queue.bd_res = malloc(g_thread_num * sizeof(struct thread_bd_res)); if (!g_thread_queue.bd_res) { ZIP_TST_PRT("malloc thread res memory fail!\n"); -- 2.33.0