diff options
author | Loic Poulain <loic.poulain@linaro.org> | 2021-02-09 16:34:23 +0100 |
---|---|---|
committer | Loic Poulain <loic.poulain@linaro.org> | 2021-02-16 16:08:24 +0100 |
commit | 7deb19fa84a8829a9b563723b910206b0e54bb50 (patch) | |
tree | f5eacb2f56f8a2c21d799b5e178ced47f5121c13 | |
parent | c9de04e24528b19168abbcb5d8db19566fe5992a (diff) |
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.
Fixes: a7f422f2f89e ("bus: mhi: Fix channel close issue on driver remove")
Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Reported-by: Kalle Valo <kvalo@codeaurora.org>
Tested-by: Kalle Valo <kvalo@codeaurora.org>
-rw-r--r-- | drivers/bus/mhi/core/init.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c index aa575d3fb3ae..be4eebb0971b 100644 --- a/drivers/bus/mhi/core/init.c +++ b/drivers/bus/mhi/core/init.c @@ -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); |