dmaengine: fix balance of privatecnt
PATCH 1/1 dmaengine: fix balance of privatecnt
dma_release_channel() decrements privatecnt counter and almost all dma_get* function increments it with the exception of dma_get_slave_channel(). In most cases this does not cause issue since normally the channel is not requested and released, but if a driver requests DMA channel via dma_get_slave_channel() and releases the channel the privatecnt will be unbalanced and this will prevent for example getting channel for memcpy.
--- drivers/dma/dmaengine.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/dma/dmaengine.c +9 -1
@@ -554,10 +554,18 @@ struct dma_chan *dma_get_slave_channel(struct dma_chan *chan)mutex_lock (&dma_list_mutex);if (chan->client_count ==0 ) { +struct dma_device *device = chan->device; + +dma_cap_set (DMA_PRIVATE , device->cap_mask); + device->privatecnt++; err =dma_chan_get (chan); -if (err) +if (err) {pr_debug ("%s: failed to get %s: (%d)\n" , __func__,dma_chan_name (chan), err); + chan =NULL ; +if (--device->privatecnt ==0 ) +dma_cap_clear (DMA_PRIVATE , device->cap_mask); + } }else chan =NULL ;
Signature · 1 line
2.5.2
Vinod Koul
AppliedQuoted 6 lines · Peter Ujfalusi
dma_release_channel()decrements privatecnt counter and almost all dma_get* function increments it with the exception ofdma_get_slave_channel(). In most cases this does not cause issue since normally the channel is not requested and released, but if a driver requests DMA channel viadma_get_slave_channel()and releases the channel the privatecnt will be unbalanced and this will prevent for example getting channel for memcpy.
Applied, thanks
Signature · 1 line
~Vinod