aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dma/dmatest.c
diff options
context:
space:
mode:
authorLaura Abbott <labbott@redhat.com>2018-04-10 21:02:16 -0400
committerVinod Koul <vinod.koul@intel.com>2018-04-16 11:35:54 -0400
commit72ef08bf651a9fab3b315b8e6d57d19926c77e4d (patch)
tree75e60525b2ec379b3a867967dc373a2047f3bf43 /drivers/dma/dmatest.c
parent60cc43fc888428bb2f18f08997432d426a243338 (diff)
dmaengine: dmatest: Remove use of VLAs
There's an ongoing effort to remove VLAs from the kernel (https://lkml.org/lkml/2018/3/7/621) to eventually turn on -Wvla. The test already pre-allocates some buffers with kmalloc so turn the two VLAs in to pre-allocated kmalloc buffers. Signed-off-by: Laura Abbott <labbott@redhat.com> Reviewed-by: Sinan Kaya <okaya@codeaurora.org> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Diffstat (limited to 'drivers/dma/dmatest.c')
-rw-r--r--drivers/dma/dmatest.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index b9339524d5bd..aa1712beb0cc 100644
--- a/drivers/dma/dmatest.c
+++ b/drivers/dma/dmatest.c
@@ -468,6 +468,8 @@ static int dmatest_func(void *data)
468 unsigned long long total_len = 0; 468 unsigned long long total_len = 0;
469 u8 align = 0; 469 u8 align = 0;
470 bool is_memset = false; 470 bool is_memset = false;
471 dma_addr_t *srcs;
472 dma_addr_t *dma_pq;
471 473
472 set_freezable(); 474 set_freezable();
473 475
@@ -551,6 +553,14 @@ static int dmatest_func(void *data)
551 553
552 set_user_nice(current, 10); 554 set_user_nice(current, 10);
553 555
556 srcs = kcalloc(src_cnt, sizeof(dma_addr_t), GFP_KERNEL);
557 if (!srcs)
558 goto err_dstbuf;
559
560 dma_pq = kcalloc(dst_cnt, sizeof(dma_addr_t), GFP_KERNEL);
561 if (!dma_pq)
562 goto err_srcs_array;
563
554 /* 564 /*
555 * src and dst buffers are freed by ourselves below 565 * src and dst buffers are freed by ourselves below
556 */ 566 */
@@ -561,7 +571,6 @@ static int dmatest_func(void *data)
561 && !(params->iterations && total_tests >= params->iterations)) { 571 && !(params->iterations && total_tests >= params->iterations)) {
562 struct dma_async_tx_descriptor *tx = NULL; 572 struct dma_async_tx_descriptor *tx = NULL;
563 struct dmaengine_unmap_data *um; 573 struct dmaengine_unmap_data *um;
564 dma_addr_t srcs[src_cnt];
565 dma_addr_t *dsts; 574 dma_addr_t *dsts;
566 unsigned int src_off, dst_off, len; 575 unsigned int src_off, dst_off, len;
567 576
@@ -676,8 +685,6 @@ static int dmatest_func(void *data)
676 srcs, src_cnt, 685 srcs, src_cnt,
677 len, flags); 686 len, flags);
678 else if (thread->type == DMA_PQ) { 687 else if (thread->type == DMA_PQ) {
679 dma_addr_t dma_pq[dst_cnt];
680
681 for (i = 0; i < dst_cnt; i++) 688 for (i = 0; i < dst_cnt; i++)
682 dma_pq[i] = dsts[i] + dst_off; 689 dma_pq[i] = dsts[i] + dst_off;
683 tx = dev->device_prep_dma_pq(chan, dma_pq, srcs, 690 tx = dev->device_prep_dma_pq(chan, dma_pq, srcs,
@@ -779,6 +786,9 @@ static int dmatest_func(void *data)
779 runtime = ktime_to_us(ktime); 786 runtime = ktime_to_us(ktime);
780 787
781 ret = 0; 788 ret = 0;
789 kfree(dma_pq);
790err_srcs_array:
791 kfree(srcs);
782err_dstbuf: 792err_dstbuf:
783 for (i = 0; thread->udsts[i]; i++) 793 for (i = 0; thread->udsts[i]; i++)
784 kfree(thread->udsts[i]); 794 kfree(thread->udsts[i]);