From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
To: Loic Poulain <loic.poulain@linaro.org>
Cc: hemantk@codeaurora.org, linux-arm-msm@vger.kernel.org,
kvalo@codeaurora.org
Subject: Re: [PATCH v2] mhi: Fix double dma free
Date: Wed, 10 Feb 2021 13:44:39 +0530 [thread overview]
Message-ID: <20210210081439.GB13668@work> (raw)
In-Reply-To: <1612894264-15956-1-git-send-email-loic.poulain@linaro.org>
On Tue, Feb 09, 2021 at 07:11:04PM +0100, Loic Poulain wrote:
> 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>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Thanks,
Mani
> ---
> v2: add Fixes tag
>
> drivers/bus/mhi/core/init.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
> index aa575d3..be4eebb 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);
> --
> 2.7.4
>
next prev parent reply other threads:[~2021-02-10 8:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-09 18:11 [PATCH v2] mhi: Fix double dma free Loic Poulain
2021-02-10 8:14 ` Manivannan Sadhasivam [this message]
2021-03-01 19:59 ` patchwork-bot+linux-arm-msm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210210081439.GB13668@work \
--to=manivannan.sadhasivam@linaro.org \
--cc=hemantk@codeaurora.org \
--cc=kvalo@codeaurora.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=loic.poulain@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).