From b34883e07baa28e52ccaaa08679a6e077051307c Mon Sep 17 00:00:00 2001 From: Ziye Yang Date: Wed, 27 Jan 2021 04:06:25 +0800 Subject: [PATCH] accel_perf: Fix the memory leak issue of task free When the task is allocated from _get_task function, the task is removed from the tasks_pool in non batched mode. So in _accel_done function, when the is_draining flag is true and it is not a batched mode, we should add task back to the pool. If not, the the memory related resource allocated by the task will not be freed. PS: In _check_draining function, the related resource of task in the tasks_pool will be freed. However, if the task is not added back, the resource free will not work as expected. PS: The issue is reported by ASAN. Signed-off-by: Ziye Yang Change-Id: I981117037fba8e111987c771cae65bc06a734a6f Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6097 Tested-by: SPDK CI Jenkins Reviewed-by: Paul Luse Reviewed-by: Changpeng Liu Reviewed-by: Aleksey Marchuk Reviewed-by: Ben Walker Community-CI: Mellanox Build Bot --- examples/accel/perf/accel_perf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/accel/perf/accel_perf.c b/examples/accel/perf/accel_perf.c index 216df26e4..76d01d52b 100644 --- a/examples/accel/perf/accel_perf.c +++ b/examples/accel/perf/accel_perf.c @@ -570,8 +570,9 @@ _accel_done(void *arg1) } } else if (g_ops_per_batch > 0) { _drain_batch(worker); + } else { + TAILQ_INSERT_TAIL(&worker->tasks_pool, task, link); } - } static int