aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJingchang Lu <b35083@freescale.com>2014-02-21 01:50:06 -0500
committerVinod Koul <vinod.koul@intel.com>2014-03-06 10:13:57 -0500
commit178c81e58e91559fd2c6b1cae43c8f573a2ead36 (patch)
tree82f08ee72646dfd319c34021abe008544adafc9e
parent7cbccb55f04bef306bc2840185ec8f986bd0df3c (diff)
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>
-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 9025300a1670..381e793184ba 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,
723 struct of_dma *ofdma) 723 struct of_dma *ofdma)
724{ 724{
725 struct fsl_edma_engine *fsl_edma = ofdma->of_dma_data; 725 struct fsl_edma_engine *fsl_edma = ofdma->of_dma_data;
726 struct dma_chan *chan; 726 struct dma_chan *chan, *_chan;
727 727
728 if (dma_spec->args_count != 2) 728 if (dma_spec->args_count != 2)
729 return NULL; 729 return NULL;
730 730
731 mutex_lock(&fsl_edma->fsl_edma_mutex); 731 mutex_lock(&fsl_edma->fsl_edma_mutex);
732 list_for_each_entry(chan, &fsl_edma->dma_dev.channels, device_node) { 732 list_for_each_entry_safe(chan, _chan, &fsl_edma->dma_dev.channels, device_node) {
733 if (chan->client_count) 733 if (chan->client_count)
734 continue; 734 continue;
735 if ((chan->chan_id / DMAMUX_NR) == dma_spec->args[0]) { 735 if ((chan->chan_id / DMAMUX_NR) == dma_spec->args[0]) {