diff options
author | Fancy Fang <chen.fang@freescale.com> | 2015-11-26 16:47:07 +0800 |
---|---|---|
committer | Nitin Garg <nitin.garg@nxp.com> | 2016-01-14 11:02:24 -0600 |
commit | 8c736959525a58ed7f06d79ace0665a64eb7521e (patch) | |
tree | c2464992812032348a5258f93b89604c0a09ee8c /drivers/dma | |
parent | 617cac54b25c9f2253cf5bb2eb1d4dfc720c0860 (diff) |
MLK-11907 dma: pxp-dev: allocate the 'sg' buffer dynamically.
The 'sg' buffer should be allocated dynamically, since its
size is dependent on the 'sg_len' which is calculated
according to the functions required.
Signed-off-by: Fancy Fang <chen.fang@freescale.com>
(cherry picked from commit 57f08c108fc4f4721449b4b94be9820c7443978a)
Diffstat (limited to 'drivers/dma')
-rw-r--r-- | drivers/dma/pxp/pxp_device.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/dma/pxp/pxp_device.c b/drivers/dma/pxp/pxp_device.c index b2716a07d4ec..a4a65a45d30c 100644 --- a/drivers/dma/pxp/pxp_device.c +++ b/drivers/dma/pxp/pxp_device.c @@ -317,7 +317,7 @@ static void pxp_dma_done(void *arg) static int pxp_ioc_config_chan(struct pxp_file *priv, unsigned long arg) { - struct scatterlist sg[3]; + struct scatterlist *sg; struct pxp_tx_desc *desc; struct dma_async_tx_descriptor *txd; struct pxp_config_data *pxp_conf; @@ -356,6 +356,12 @@ static int pxp_ioc_config_chan(struct pxp_file *priv, unsigned long arg) if (pxp_conf->proc_data.engine_enable & PXP_ENABLE_DITHER) sg_len += 4; + sg = kmalloc(sizeof(*sg) * sg_len, GFP_KERNEL); + if (!sg) { + kfree(pxp_conf); + return -ENOMEM; + } + sg_init_table(sg, sg_len); txd = chan->device->device_prep_slave_sg(chan, @@ -366,6 +372,7 @@ static int pxp_ioc_config_chan(struct pxp_file *priv, unsigned long arg) if (!txd) { pr_err("Error preparing a DMA transaction descriptor.\n"); kfree(pxp_conf); + kfree(sg); return -EIO; } @@ -488,12 +495,14 @@ static int pxp_ioc_config_chan(struct pxp_file *priv, unsigned long arg) if (cookie < 0) { pr_err("Error tx_submit\n"); kfree(pxp_conf); + kfree(sg); return -EIO; } atomic_inc(&irq_info[chan_id].irq_pending); kfree(pxp_conf); + kfree(sg); return 0; } |