mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 20:51:44 +00:00
mhi: Fix double dma free
mhi_deinit_chan_ctxt functionthat takes care of unitializing channel
resources, including unmapping coherent MHI areas, can be called
from different path in case of controller unregistering/removal:
- From a client driver remove callback, via mhi_unprepare_channel
- From mhi_driver_remove that unitialize all channels
mhi_driver_remove()
|-> driver->remove()
| |-> mhi_unprepare_channel()
| |-> mhi_deinit_chan_ctxt()
|...
|-> mhi_deinit_chan_ctxt()
This leads to double dma freeing...
Fix that by preventing deinit for already uninitialized channel.
Link: https://lore.kernel.org/r/1612894264-15956-1-git-send-email-loic.poulain@linaro.org
Fixes: a7f422f2f8
("bus: mhi: Fix channel close issue on driver remove")
Reported-by: Kalle Valo <kvalo@codeaurora.org>
Tested-by: Kalle Valo <kvalo@codeaurora.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/20210210082538.2494-2-manivannan.sadhasivam@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
0566752c3e
commit
db4e8de193
@ -557,6 +557,9 @@ void mhi_deinit_chan_ctxt(struct mhi_controller *mhi_cntrl,
|
||||
tre_ring = &mhi_chan->tre_ring;
|
||||
chan_ctxt = &mhi_cntrl->mhi_ctxt->chan_ctxt[mhi_chan->chan];
|
||||
|
||||
if (!chan_ctxt->rbase) /* Already uninitialized */
|
||||
return;
|
||||
|
||||
mhi_free_coherent(mhi_cntrl, tre_ring->alloc_size,
|
||||
tre_ring->pre_aligned, tre_ring->dma_handle);
|
||||
vfree(buf_ring->base);
|
||||
|
Loading…
Reference in New Issue
Block a user