From: Vinod Koul Date: Mon, 19 Aug 2013 05:17:26 +0000 (+0530) Subject: dmaengine: fix - error: potential NULL dereference 'chan' X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=d9a6c8f52d1039333bef6234126485409e8f7501;p=openwrt%2Fstaging%2Fblogic.git dmaengine: fix - error: potential NULL dereference 'chan' commit 7bb587f4 "dmaengine: add interface of dma_get_slave_channel" introduced the above error so fix it Reported-by: Dan Carpenter Suggested-by: Zhangfei Gao Signed-off-by: Vinod Koul --- diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index 5932ab164ace..755ba2f4f1d5 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c @@ -514,16 +514,16 @@ struct dma_chan *dma_get_slave_channel(struct dma_chan *chan) /* lock against __dma_request_channel */ mutex_lock(&dma_list_mutex); - if (chan->client_count == 0) + if (chan->client_count == 0) { err = dma_chan_get(chan); - else + if (err) + pr_debug("%s: failed to get %s: (%d)\n", + __func__, dma_chan_name(chan), err); + } else chan = NULL; mutex_unlock(&dma_list_mutex); - if (err) - pr_debug("%s: failed to get %s: (%d)\n", - __func__, dma_chan_name(chan), err); return chan; }