diff options
author | Alexandru Ardelean <alexandru.ardelean@analog.com> | 2018-11-01 18:07:16 +0200 |
---|---|---|
committer | Vinod Koul <vkoul@kernel.org> | 2018-11-24 19:21:16 +0530 |
commit | 787d3083caf899b8c3abf5a0c7a04e79d77f2c32 (patch) | |
tree | 2c50911e4ecac79889888e73d02d83577a1158d0 /drivers/dma/dmatest.c | |
parent | fbffb6b4d44f1263390130cb8b35cabc030af3f7 (diff) |
dmaengine: dmatest: move size checks earlier in function
There's no need to allocate all that memory if these sizes are invalid
anyway.
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Diffstat (limited to 'drivers/dma/dmatest.c')
-rw-r--r-- | drivers/dma/dmatest.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c index 214391ba019a..e71aa1e3451c 100644 --- a/drivers/dma/dmatest.c +++ b/drivers/dma/dmatest.c @@ -507,6 +507,19 @@ static int dmatest_func(void *data) } else goto err_thread_type; + /* Check if buffer count fits into map count variable (u8) */ + if ((src_cnt + dst_cnt) >= 255) { + pr_err("too many buffers (%d of 255 supported)\n", + src_cnt + dst_cnt); + goto err_thread_type; + } + + if (1 << align > params->buf_size) { + pr_err("%u-byte buffer too small for %d-byte alignment\n", + params->buf_size, 1 << align); + goto err_thread_type; + } + thread->srcs = kcalloc(src_cnt + 1, sizeof(u8 *), GFP_KERNEL); if (!thread->srcs) goto err_srcs; @@ -576,19 +589,6 @@ static int dmatest_func(void *data) total_tests++; - /* Check if buffer count fits into map count variable (u8) */ - if ((src_cnt + dst_cnt) >= 255) { - pr_err("too many buffers (%d of 255 supported)\n", - src_cnt + dst_cnt); - break; - } - - if (1 << align > params->buf_size) { - pr_err("%u-byte buffer too small for %d-byte alignment\n", - params->buf_size, 1 << align); - break; - } - if (params->norandom) len = params->buf_size; else |