summaryrefslogtreecommitdiffstats
path: root/drivers/dma/ioat
diff options
context:
space:
mode:
authorDave Jiang <dave.jiang@intel.com>2015-08-25 12:58:11 -0700
committerVinod Koul <vinod.koul@intel.com>2015-08-26 07:53:58 +0530
commit7b7d0ca7778d359584859cb5e75965ad34f42533 (patch)
tree6f4fdd86026e38af82fe190436d6001c911b1fc8 /drivers/dma/ioat
parent5c65cb93a3d066f52a109552572304675d5a52fc (diff)
downloadop-kernel-dev-7b7d0ca7778d359584859cb5e75965ad34f42533.zip
op-kernel-dev-7b7d0ca7778d359584859cb5e75965ad34f42533.tar.gz
dmaengine: ioatdma: Fix variable array length
Sparse reported: drivers/dma/ioat/prep.c:637:27: sparse: Variable length array is used. Assigning a static value for the array. Signed-off-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Diffstat (limited to 'drivers/dma/ioat')
-rw-r--r--drivers/dma/ioat/prep.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/dma/ioat/prep.c b/drivers/dma/ioat/prep.c
index e323a40..ad4fb41 100644
--- a/drivers/dma/ioat/prep.c
+++ b/drivers/dma/ioat/prep.c
@@ -26,6 +26,8 @@
#include "hw.h"
#include "dma.h"
+#define MAX_SCF 1024
+
/* provide a lookup table for setting the source address in the base or
* extended descriptor of an xor or pq descriptor
*/
@@ -634,9 +636,12 @@ struct dma_async_tx_descriptor *
ioat_prep_pqxor(struct dma_chan *chan, dma_addr_t dst, dma_addr_t *src,
unsigned int src_cnt, size_t len, unsigned long flags)
{
- unsigned char scf[src_cnt];
+ unsigned char scf[MAX_SCF];
dma_addr_t pq[2];
+ if (src_cnt > MAX_SCF)
+ return NULL;
+
memset(scf, 0, src_cnt);
pq[0] = dst;
flags |= DMA_PREP_PQ_DISABLE_Q;
@@ -654,9 +659,12 @@ ioat_prep_pqxor_val(struct dma_chan *chan, dma_addr_t *src,
unsigned int src_cnt, size_t len,
enum sum_check_flags *result, unsigned long flags)
{
- unsigned char scf[src_cnt];
+ unsigned char scf[MAX_SCF];
dma_addr_t pq[2];
+ if (src_cnt > MAX_SCF)
+ return NULL;
+
/* the cleanup routine only sets bits on validate failure, it
* does not clear bits on validate success... so clear it here
*/
OpenPOWER on IntegriCloud