* dmaengine: dmatest: move size checks earlier in function
@ 2018-11-01 16:07 Alexandru Ardelean
0 siblings, 0 replies; 2+ messages in thread
From: Alexandru Ardelean @ 2018-11-01 16:07 UTC (permalink / raw)
To: dmaengine, vkoul; +Cc: Alexandru Ardelean
There's no need to allocate all that memory if these sizes are invalid
anyway.
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---
drivers/dma/dmatest.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index aa1712beb0cc..fa991e095ef2 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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* dmaengine: dmatest: move size checks earlier in function
@ 2018-11-24 13:51 Vinod Koul
0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2018-11-24 13:51 UTC (permalink / raw)
To: Alexandru Ardelean; +Cc: dmaengine
On 01-11-18, 18:07, Alexandru Ardelean wrote:
> There's no need to allocate all that memory if these sizes are invalid
> anyway.
Applied, thanks
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-11-24 13:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-01 16:07 dmaengine: dmatest: move size checks earlier in function Alexandru Ardelean
2018-11-24 13:51 Vinod Koul
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.