dmaengine: stm32-dma: Fix unchecked deference of chan->desc

'commit d8b468394f ("dmaengine: Add STM32 DMA driver")' leads to the
following Smatch complaint:

drivers/dma/stm32-dma.c:562 stm32_dma_issue_pending()
    error: we previously assumed 'chan->desc' could be null (see line 560)

So, this patch fixes the unchecked dereference of chan->desc by returning
operation not permitted error when stm32_dma_start_transfer() does not
succeed to allocate a virtual channel descriptor.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: M'boumba Cedric Madianga <cedric.madianga@gmail.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
This commit is contained in:
M'boumba Cedric Madianga 2015-12-07 12:00:28 +01:00 committed by Vinod Koul
parent b341b4a13c
commit aea08a5dfa

View File

@ -437,7 +437,7 @@ static int stm32_dma_start_transfer(struct stm32_dma_chan *chan)
if (!chan->desc) {
vdesc = vchan_next_desc(&chan->vchan);
if (!vdesc)
return 0;
return -EPERM;
chan->desc = to_stm32_dma_desc(vdesc);
chan->next_sg = 0;
@ -559,7 +559,7 @@ static void stm32_dma_issue_pending(struct dma_chan *c)
if (!chan->busy) {
if (vchan_issue_pending(&chan->vchan) && !chan->desc) {
ret = stm32_dma_start_transfer(chan);
if ((chan->desc->cyclic) && (!ret))
if ((!ret) && (chan->desc->cyclic))
stm32_dma_configure_next_sg(chan);
}
}