kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ulf Hansson <ulf.hansson@linaro.org>
To: Colin King <colin.king@canonical.com>
Cc: Xiyu Yang <xiyuyang19@fudan.edu.cn>,
	Xin Tan <tanxin.ctf@gmail.com>,
	linux-mmc <linux-mmc@vger.kernel.org>,
	kernel-janitors@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH][next] mmc: moxart: Fix null pointer dereference on pointer host
Date: Thu, 14 Oct 2021 13:24:07 +0200	[thread overview]
Message-ID: <CAPDyKFp7jsEPjun=2mTDGrGM=mHM=jUQvGwDObfMx8odQ9d2Ag@mail.gmail.com> (raw)
In-Reply-To: <20211013100052.125461-1-colin.king@canonical.com>

On Wed, 13 Oct 2021 at 12:00, Colin King <colin.king@canonical.com> wrote:
>
> From: Colin Ian King <colin.king@canonical.com>
>
> There are several error return paths that dereference the null pointer
> host because the pointer has not yet been set to a valid value.
> Fix this by adding a new out_mmc label and exiting via this label
> to avoid the host clean up and hence the null pointer dereference.
>
> Addresses-Coverity: ("Explicit null dereference")
> Fixes: 8105c2abbf36 ("mmc: moxart: Fix reference count leaks in moxart_probe")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied for next, thanks!

Kind regards
Uffe

> ---
>  drivers/mmc/host/moxart-mmc.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/mmc/host/moxart-mmc.c b/drivers/mmc/host/moxart-mmc.c
> index 7b9fcef490de..16d1c7a43d33 100644
> --- a/drivers/mmc/host/moxart-mmc.c
> +++ b/drivers/mmc/host/moxart-mmc.c
> @@ -566,37 +566,37 @@ static int moxart_probe(struct platform_device *pdev)
>         if (!mmc) {
>                 dev_err(dev, "mmc_alloc_host failed\n");
>                 ret = -ENOMEM;
> -               goto out;
> +               goto out_mmc;
>         }
>
>         ret = of_address_to_resource(node, 0, &res_mmc);
>         if (ret) {
>                 dev_err(dev, "of_address_to_resource failed\n");
> -               goto out;
> +               goto out_mmc;
>         }
>
>         irq = irq_of_parse_and_map(node, 0);
>         if (irq <= 0) {
>                 dev_err(dev, "irq_of_parse_and_map failed\n");
>                 ret = -EINVAL;
> -               goto out;
> +               goto out_mmc;
>         }
>
>         clk = devm_clk_get(dev, NULL);
>         if (IS_ERR(clk)) {
>                 ret = PTR_ERR(clk);
> -               goto out;
> +               goto out_mmc;
>         }
>
>         reg_mmc = devm_ioremap_resource(dev, &res_mmc);
>         if (IS_ERR(reg_mmc)) {
>                 ret = PTR_ERR(reg_mmc);
> -               goto out;
> +               goto out_mmc;
>         }
>
>         ret = mmc_of_parse(mmc);
>         if (ret)
> -               goto out;
> +               goto out_mmc;
>
>         host = mmc_priv(mmc);
>         host->mmc = mmc;
> @@ -687,6 +687,7 @@ static int moxart_probe(struct platform_device *pdev)
>                 dma_release_channel(host->dma_chan_tx);
>         if (!IS_ERR_OR_NULL(host->dma_chan_rx))
>                 dma_release_channel(host->dma_chan_rx);
> +out_mmc:
>         if (mmc)
>                 mmc_free_host(mmc);
>         return ret;
> --
> 2.32.0
>

      reply	other threads:[~2021-10-14 11:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-13 10:00 [PATCH][next] mmc: moxart: Fix null pointer dereference on pointer host Colin King
2021-10-14 11:24 ` 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='CAPDyKFp7jsEPjun=2mTDGrGM=mHM=jUQvGwDObfMx8odQ9d2Ag@mail.gmail.com' \
    --to=ulf.hansson@linaro.org \
    --cc=colin.king@canonical.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=tanxin.ctf@gmail.com \
    --cc=xiyuyang19@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).