Commit 3f3c7554 authored by Dan Carpenter's avatar Dan Carpenter Committed by Vinod Koul

dmaengine: dmatest: fix a small memory leak in dmatest_func()

We recently moved the test size tests around but it means we need to
adjust the error handling as well or we leak the "pq_coefs" memory.  I
updated the label name to reflect that we're freeing coefs.

Fixes: 787d3083 ("dmaengine: dmatest: move size checks earlier in function")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 787d3083
...@@ -511,18 +511,18 @@ static int dmatest_func(void *data) ...@@ -511,18 +511,18 @@ static int dmatest_func(void *data)
if ((src_cnt + dst_cnt) >= 255) { if ((src_cnt + dst_cnt) >= 255) {
pr_err("too many buffers (%d of 255 supported)\n", pr_err("too many buffers (%d of 255 supported)\n",
src_cnt + dst_cnt); src_cnt + dst_cnt);
goto err_thread_type; goto err_free_coefs;
} }
if (1 << align > params->buf_size) { if (1 << align > params->buf_size) {
pr_err("%u-byte buffer too small for %d-byte alignment\n", pr_err("%u-byte buffer too small for %d-byte alignment\n",
params->buf_size, 1 << align); params->buf_size, 1 << align);
goto err_thread_type; goto err_free_coefs;
} }
thread->srcs = kcalloc(src_cnt + 1, sizeof(u8 *), GFP_KERNEL); thread->srcs = kcalloc(src_cnt + 1, sizeof(u8 *), GFP_KERNEL);
if (!thread->srcs) if (!thread->srcs)
goto err_srcs; goto err_free_coefs;
thread->usrcs = kcalloc(src_cnt + 1, sizeof(u8 *), GFP_KERNEL); thread->usrcs = kcalloc(src_cnt + 1, sizeof(u8 *), GFP_KERNEL);
if (!thread->usrcs) if (!thread->usrcs)
...@@ -800,7 +800,7 @@ static int dmatest_func(void *data) ...@@ -800,7 +800,7 @@ static int dmatest_func(void *data)
kfree(thread->usrcs); kfree(thread->usrcs);
err_usrcs: err_usrcs:
kfree(thread->srcs); kfree(thread->srcs);
err_srcs: err_free_coefs:
kfree(pq_coefs); kfree(pq_coefs);
err_thread_type: err_thread_type:
pr_info("%s: summary %u tests, %u failures %llu iops %llu KB/s (%d)\n", pr_info("%s: summary %u tests, %u failures %llu iops %llu KB/s (%d)\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment