From: Ulf Hansson <ulf.hansson@linaro.org>
To: Xin Xiong <xiongx18@fudan.edu.cn>
Cc: linux-mmc <linux-mmc@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
yuanxzhang@fudan.edu.cn, Xiyu Yang <xiyuyang19@fudan.edu.cn>,
Xin Tan <tanxin.ctf@gmail.com>
Subject: Re: [PATCH v2] drivers/mmc: fix reference count leaks in moxart_probe
Date: Tue, 28 Sep 2021 00:32:27 +0200 [thread overview]
Message-ID: <CAPDyKFoeA01fy6pAcSu2qaqs9U2VcgTLSvhzvNObhhprPdDT9g@mail.gmail.com> (raw)
In-Reply-To: <20210927015759.30855-1-xiongx18@fudan.edu.cn>
On Mon, 27 Sept 2021 at 04:00, Xin Xiong <xiongx18@fudan.edu.cn> wrote:
>
> The issue happens in several error handling paths on two refcounted
> object related to the object "host" (dma_chan_rx, dma_chan_tx). In
> these paths, the function forgets to decrement one or both objects'
> reference count increased earlier by dma_request_chan(), causing
> reference count leaks.
>
> Fix it by balancing the refcounts of both objects in some error
> handling paths.
>
> Signed-off-by: Xin Xiong <xiongx18@fudan.edu.cn>
> Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
> Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
The code looks good to me! However, checkpatch is complaining about
the format. Please run it and fixup the reported warnings/errors.
Kind regards
Üffe
> ---
> drivers/mmc/host/moxart-mmc.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/mmc/host/moxart-mmc.c b/drivers/mmc/host/moxart-mmc.c
> index 6c9d38132..e27ab3446 100644
> --- a/drivers/mmc/host/moxart-mmc.c
> +++ b/drivers/mmc/host/moxart-mmc.c
> @@ -621,6 +621,14 @@ static int moxart_probe(struct platform_device *pdev)
> ret = -EPROBE_DEFER;
> goto out;
> }
> + if (!IS_ERR(host->dma_chan_tx)) {
> + dma_release_channel(host->dma_chan_tx);
> + host->dma_chan_tx = NULL;
> + }
> + if (!IS_ERR(host->dma_chan_rx)) {
> + dma_release_channel(host->dma_chan_rx);
> + host->dma_chan_rx = NULL;
> + }
> dev_dbg(dev, "PIO mode transfer enabled\n");
> host->have_dma = false;
> } else {
> @@ -675,6 +683,10 @@ static int moxart_probe(struct platform_device *pdev)
> return 0;
>
> out:
> + if (!IS_ERR_OR_NULL(host->dma_chan_tx))
> + dma_release_channel(host->dma_chan_tx);
> + if (!IS_ERR_OR_NULL(host->dma_chan_rx))
> + dma_release_channel(host->dma_chan_rx);
> if (mmc)
> mmc_free_host(mmc);
> return ret;
> --
> 2.25.1
>
prev parent reply other threads:[~2021-09-27 22:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-27 1:57 [PATCH v2] drivers/mmc: fix reference count leaks in moxart_probe Xin Xiong
2021-09-27 22:32 ` Ulf Hansson [this message]
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=CAPDyKFoeA01fy6pAcSu2qaqs9U2VcgTLSvhzvNObhhprPdDT9g@mail.gmail.com \
--to=ulf.hansson@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=tanxin.ctf@gmail.com \
--cc=xiongx18@fudan.edu.cn \
--cc=xiyuyang19@fudan.edu.cn \
--cc=yuanxzhang@fudan.edu.cn \
/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).