Commit 877d8425072b50965f6f04ea3a127928f66db72f

Authored by Vinod Koul
1 parent 9d9f71a804

dmaengine: sh: don't use dynamic static allocation

dynamic stack allocation in kernel is considered bad as kernel stack is low and
we get warns on few archs as reported by kbuild test robot

>> drivers/dma/sh/shdma-base.c:671:32: sparse: Variable length array is used.
>> drivers/dma/sh/shdma-base.c:701:1: warning: 'shdma_prep_dma_cyclic' uses
>> dynamic stack allocation [enabled by default]

Fix this by making a static array of 32 which should be sufficient for
shdma_prep_dma_cyclic which only user in kernel is audio and 32 periods for
audio seems quite sufficient atm

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>

Showing 1 changed file with 9 additions and 1 deletions Side-by-side Diff

drivers/dma/sh/shdma-base.c
... ... @@ -657,6 +657,8 @@
657 657 direction, flags, false);
658 658 }
659 659  
  660 +#define SHDMA_MAX_SG_LEN 32
  661 +
660 662 static struct dma_async_tx_descriptor *shdma_prep_dma_cyclic(
661 663 struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len,
662 664 size_t period_len, enum dma_transfer_direction direction,
663 665  
... ... @@ -668,13 +670,19 @@
668 670 unsigned int sg_len = buf_len / period_len;
669 671 int slave_id = schan->slave_id;
670 672 dma_addr_t slave_addr;
671   - struct scatterlist sgl[sg_len];
  673 + struct scatterlist sgl[SHDMA_MAX_SG_LEN];
672 674 int i;
673 675  
674 676 if (!chan)
675 677 return NULL;
676 678  
677 679 BUG_ON(!schan->desc_num);
  680 +
  681 + if (sg_len > SHDMA_MAX_SG_LEN) {
  682 + dev_err(schan->dev, "sg length %d exceds limit %d",
  683 + sg_len, SHDMA_MAX_SG_LEN);
  684 + return NULL;
  685 + }
678 686  
679 687 /* Someone calling slave DMA on a generic channel? */
680 688 if (slave_id < 0 || (buf_len < period_len)) {