public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dmaengine: dmatest: Remove use of VLAs
@ 2018-04-09 21:06 Laura Abbott
  2018-04-09 22:48 ` Sinan Kaya
  2018-04-10  4:00 ` kbuild test robot
  0 siblings, 2 replies; 6+ messages in thread
From: Laura Abbott @ 2018-04-09 21:06 UTC (permalink / raw)
  To: Vinod Koul, Dan Williams
  Cc: Laura Abbott, dmaengine, linux-kernel, kernel-hardening,
	Kees Cook

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 uses in dmatest are bounded by a check to make sure they fit
in a u8 so use that as an upper bound.

Signed-off-by: Laura Abbott <labbott@redhat.com>
---
 drivers/dma/dmatest.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index 80cc2be6483c..dcf787b173e4 100644
--- a/drivers/dma/dmatest.c
+++ b/drivers/dma/dmatest.c
@@ -556,7 +556,8 @@ static int dmatest_func(void *data)
 	       && !(params->iterations && total_tests >= params->iterations)) {
 		struct dma_async_tx_descriptor *tx = NULL;
 		struct dmaengine_unmap_data *um;
-		dma_addr_t srcs[src_cnt];
+		/* total buffer count must fit into u8 */
+		dma_addr_t srcs[255];
 		dma_addr_t *dsts;
 		unsigned int src_off, dst_off, len;
 
@@ -669,7 +670,8 @@ static int dmatest_func(void *data)
 						      srcs, src_cnt,
 						      len, flags);
 		else if (thread->type == DMA_PQ) {
-			dma_addr_t dma_pq[dst_cnt];
+			/* dst_cnt can't be more than u8 */
+			dma_addr_t dma_pq[255];
 
 			for (i = 0; i < dst_cnt; i++)
 				dma_pq[i] = dsts[i] + dst_off;
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-04-10 15:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-09 21:06 [PATCH] dmaengine: dmatest: Remove use of VLAs Laura Abbott
2018-04-09 22:48 ` Sinan Kaya
2018-04-09 23:14   ` Laura Abbott
2018-04-09 23:19     ` okaya
2018-04-10 15:38     ` Vinod Koul
2018-04-10  4:00 ` kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox