dmaengine: Call module_put() after device_free_chan_resources()

The module reference is taken to ensure the callbacks still exist
when they are called. If the channel holds the last reference to the
module, the module can disappear before device_free_chan_resources() is
called and would cause a call into free'd memory.

Signed-off-by: Logan Gunthorpe <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Vinod Koul <[email protected]>
This commit is contained in:
Logan Gunthorpe authored and Vinod Koul committed 2019-12-24 10:18:32 +05:30
1 parent dae7a589c1
commit 686607106f
1 file changed
+2 -1
+2 -1
View File
@@ -250,7 +250,6 @@ static void dma_chan_put(struct dma_chan *chan)
return;
chan->client_count--;
module_put(dma_chan_to_owner(chan));
/* This channel is not in use anymore, free it */
if (!chan->client_count && chan->device->device_free_chan_resources) {
@@ -259,6 +258,8 @@ static void dma_chan_put(struct dma_chan *chan)
chan->device->device_free_chan_resources(chan);
}
module_put(dma_chan_to_owner(chan));
/* If the channel is used via a DMA request router, free the mapping */
if (chan->router && chan->router->route_free) {
chan->router->route_free(chan->router->dev, chan->route_data);