summaryrefslogtreecommitdiff
path: root/drivers/dma
diff options
context:
space:
mode:
authorJingchang Lu <b35083@freescale.com>2014-02-21 06:50:06 (GMT)
committerMatthew Weigel <Matthew.Weigel@freescale.com>2014-12-11 18:35:38 (GMT)
commit47f50b7e820f616ada529bbe10f7219490fad3ac (patch)
treefb1e8fb740bfc7833be8170b2575e0c0e319e961 /drivers/dma
parent71a6c0cd5defd26d33a570e6a590122af9d830df (diff)
downloadlinux-fsl-qoriq-47f50b7e820f616ada529bbe10f7219490fad3ac.tar.xz
dma: fsl-edma: fix static checker warning of NULL dereference
The static checker reports following warning: drivers/dma/fsl-edma.c:732 fsl_edma_xlate() error: we previously assumed 'chan' could be null (see line 737) The changes of the loop cursor in the iteration may result in NULL dereference when dma_get_slave_channel failed but loop will continue. So use list_for_each_entry_safe() instead of list_for_each_entry() to against this. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Jingchang Lu <b35083@freescale.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com> --- This patch is pulled back from upstream: commit 178c81e58e91559fd2c6b1cae43c8f573a2ead36
Diffstat (limited to 'drivers/dma')
-rw-r--r--drivers/dma/fsl-edma.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/dma/fsl-edma.c b/drivers/dma/fsl-edma.c
index 9025300..381e793 100644
--- a/drivers/dma/fsl-edma.c
+++ b/drivers/dma/fsl-edma.c
@@ -723,13 +723,13 @@ static struct dma_chan *fsl_edma_xlate(struct of_phandle_args *dma_spec,
struct of_dma *ofdma)
{
struct fsl_edma_engine *fsl_edma = ofdma->of_dma_data;
- struct dma_chan *chan;
+ struct dma_chan *chan, *_chan;
if (dma_spec->args_count != 2)
return NULL;
mutex_lock(&fsl_edma->fsl_edma_mutex);
- list_for_each_entry(chan, &fsl_edma->dma_dev.channels, device_node) {
+ list_for_each_entry_safe(chan, _chan, &fsl_edma->dma_dev.channels, device_node) {
if (chan->client_count)
continue;
if ((chan->chan_id / DMAMUX_NR) == dma_spec->args[0]) {