dmaengine: fix - error: potential NULL dereference 'chan'
authorVinod Koul <vinod.koul@intel.com>
Mon, 19 Aug 2013 05:17:26 +0000 (10:47 +0530)
committerVinod Koul <vinod.koul@intel.com>
Mon, 19 Aug 2013 05:18:13 +0000 (10:48 +0530)
commit 7bb587f4 "dmaengine: add interface of dma_get_slave_channel" introduced
the above error so fix it

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Suggested-by: Zhangfei Gao <zhangfei.gao@linaro.org>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
drivers/dma/dmaengine.c

index 5932ab164ace0ea6904497d38aef78ef12a61b80..755ba2f4f1d538e8db370aed4496ea8b8defd99b 100644 (file)
@@ -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;
 }