mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ulf Hansson <ulf.hansson@linaro.org>
To: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Cc: tonyhuang.sunplus@gmail.com, lhjeff911@gmail.com,
	dan.carpenter@linaro.org, arnd@arndb.de,
	linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
	error27@gmail.com, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH next v2 1/2] mmc: sunplus: Fix error handling in spmmc_drv_probe()
Date: Wed, 9 Aug 2023 13:17:40 +0200	[thread overview]
Message-ID: <CAPDyKFonen0YSAHqX8MMaYfQPUDFrHUY4DUWkNrc4kxzyUWfUg@mail.gmail.com> (raw)
In-Reply-To: <CAPDyKFrstv47OdXeFvSArKwAh40Lq=JXLYfbd8LNCOwAT=b5Cw@mail.gmail.com>

On Wed, 9 Aug 2023 at 13:08, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
> On Wed, 9 Aug 2023 at 09:18, Harshit Mogalapalli
> <harshit.m.mogalapalli@oracle.com> wrote:
> >
> > When mmc allocation succeeds, the error paths are not freeing mmc.
> >
> > Fix the above issue by changing mmc_alloc_host() to devm_mmc_alloc_host()
> > to simplify the error handling. Remove label 'probe_free_host' as devm_*
> > api takes care of freeing, also remove mmc_free_host() from remove
> > function as devm_* takes care of freeing.
> >
> > Fixes: 4e268fed8b18 ("mmc: Add mmc driver for Sunplus SP7021")
> > Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> > Closes: https://lore.kernel.org/all/a3829ed3-d827-4b9d-827e-9cc24a3ec3bc@moroto.mountain/
> > Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
>
> This doesn't apply on my next branch, please rebase it.
>
> Moreover, it looks like you should replace a few more "goto
> probe_free_host;" with "return ret;". Please have a closer look.

Oh, my bad, please ignore the above!

I had another fix for the sunplus driver queued on my next branch. I
have moved that patch to fixes and applied your patch on top, thanks!

Kind regards
Uffe

> > ---
> > This is based on static analysis with smatch, only compile tested.
> >
> > v1->v2: Simplify code by using devm_mmc_alloc_host() instead of
> > mmc_alloc_host() (Ulf Hansson's suggestion)
> > ---
> >  drivers/mmc/host/sunplus-mmc.c | 14 +++-----------
> >  1 file changed, 3 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/mmc/host/sunplus-mmc.c b/drivers/mmc/host/sunplus-mmc.c
> > index a55a87f64d2a..2bdebeb1f8e4 100644
> > --- a/drivers/mmc/host/sunplus-mmc.c
> > +++ b/drivers/mmc/host/sunplus-mmc.c
> > @@ -863,11 +863,9 @@ static int spmmc_drv_probe(struct platform_device *pdev)
> >         struct spmmc_host *host;
> >         int ret = 0;
> >
> > -       mmc = mmc_alloc_host(sizeof(*host), &pdev->dev);
> > -       if (!mmc) {
> > -               ret = -ENOMEM;
> > -               goto probe_free_host;
> > -       }
> > +       mmc = devm_mmc_alloc_host(&pdev->dev, sizeof(struct spmmc_host));
> > +       if (!mmc)
> > +               return -ENOMEM;
> >
> >         host = mmc_priv(mmc);
> >         host->mmc = mmc;
> > @@ -938,11 +936,6 @@ static int spmmc_drv_probe(struct platform_device *pdev)
> >
> >  clk_disable:
> >         clk_disable_unprepare(host->clk);
> > -
> > -probe_free_host:
> > -       if (mmc)
> > -               mmc_free_host(mmc);
> > -
> >         return ret;
> >  }
> >
> > @@ -956,7 +949,6 @@ static int spmmc_drv_remove(struct platform_device *dev)
> >         pm_runtime_put_noidle(&dev->dev);
> >         pm_runtime_disable(&dev->dev);
> >         platform_set_drvdata(dev, NULL);
> > -       mmc_free_host(host->mmc);
> >
> >         return 0;
> >  }
> > --
> > 2.39.3
> >

      reply	other threads:[~2023-08-09 11:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-09  7:18 Harshit Mogalapalli
2023-08-09  7:18 ` [PATCH next v2 2/2] mmc: sunplus: Fix platform_get_irq() error checking Harshit Mogalapalli
2023-08-09 11:33   ` Ulf Hansson
2023-08-09 11:51     ` Dan Carpenter
2023-08-09 13:41       ` Ulf Hansson
2023-08-09  7:40 ` [PATCH next v2 1/2] mmc: sunplus: Fix error handling in spmmc_drv_probe() Dan Carpenter
2023-08-09 11:08 ` Ulf Hansson
2023-08-09 11:17   ` 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=CAPDyKFonen0YSAHqX8MMaYfQPUDFrHUY4DUWkNrc4kxzyUWfUg@mail.gmail.com \
    --to=ulf.hansson@linaro.org \
    --cc=arnd@arndb.de \
    --cc=dan.carpenter@linaro.org \
    --cc=error27@gmail.com \
    --cc=harshit.m.mogalapalli@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=lhjeff911@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=tonyhuang.sunplus@gmail.com \
    /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

all inboxes | Powered by JetHome®