mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
dmaengine: Store module owner in dma_device struct
[ Upstream commit dae7a589c18a4d979d5f14b09374e871b995ceb1 ] dma_chan_to_owner() dereferences the driver from the struct device to obtain the owner and call module_[get|put](). However, if the backing device is unbound before the dma_device is unregistered, the driver will be cleared and this will cause a NULL pointer dereference. Instead, store a pointer to the owner module in the dma_device struct so the module reference can be properly put when the channel is put, even if the backing device was destroyed first. This change helps to support a safer unbind of DMA engines. If the dma_device is unregistered in the driver's remove function, there's no guarantee that there are no existing clients and a users action may trigger the WARN_ONCE in dma_async_device_unregister() which is unlikely to leave the system in a consistent state. Instead, a better approach is to allow the backing driver to go away and fail any subsequent requests to it. Signed-off-by: Logan Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
This commit is contained in:
parent
93a3eff6fa
commit
f99958a96c
2 changed files with 5 additions and 1 deletions
|
|
@ -179,7 +179,7 @@ __dma_device_satisfies_mask(struct dma_device *device,
|
|||
|
||||
static struct module *dma_chan_to_owner(struct dma_chan *chan)
|
||||
{
|
||||
return chan->device->dev->driver->owner;
|
||||
return chan->device->owner;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -919,6 +919,8 @@ int dma_async_device_register(struct dma_device *device)
|
|||
return -EIO;
|
||||
}
|
||||
|
||||
device->owner = device->dev->driver->owner;
|
||||
|
||||
if (dma_has_cap(DMA_MEMCPY, device->cap_mask) && !device->device_prep_dma_memcpy) {
|
||||
dev_err(device->dev,
|
||||
"Device claims capability %s, but op is not defined\n",
|
||||
|
|
|
|||
Loading…
Reference in a new issue