linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	alexandru.marginean@nxp.com, Laurentiu.Tudor@nxp.com,
	Hui Song <hui.song_1@nxp.com>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	Ran Wang <ran.wang_1@nxp.com>,
	linux-gpio <linux-gpio@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors <kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH 2/3] gpio: mpc8xxx: Fix a potential double iounmap call in 'mpc8xxx_probe()'
Date: Tue, 31 Aug 2021 12:10:58 +0200	[thread overview]
Message-ID: <CAMpxmJX+diO-d-0sxFheMyPYJGxun6QOzddP-hrnU=ac2hSCKw@mail.gmail.com> (raw)
In-Reply-To: <5341e631dc93902ef13840807163a2883764b8ed.1629472813.git.christophe.jaillet@wanadoo.fr>

On Fri, Aug 20, 2021 at 5:38 PM Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> Commit 76c47d1449fc ("gpio: mpc8xxx: Add ACPI support") has switched to a
> managed version when dealing with 'mpc8xxx_gc->regs'. So the corresponding
> 'iounmap()' call in the error handling path and in the remove should be
> removed to avoid a double unmap.
>
> This also allows some simplification in the probe. All the error handling
> paths related to managed resources can be direct returns and a NULL check
> in what remains in the error handling path can be removed.
>
> Fixes: 76c47d1449fc ("gpio: mpc8xxx: Add ACPI support")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/gpio/gpio-mpc8xxx.c | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c
> index 241bcc80612e..fa4aaeced3f1 100644
> --- a/drivers/gpio/gpio-mpc8xxx.c
> +++ b/drivers/gpio/gpio-mpc8xxx.c
> @@ -332,7 +332,7 @@ static int mpc8xxx_probe(struct platform_device *pdev)
>                                  mpc8xxx_gc->regs + GPIO_DIR, NULL,
>                                  BGPIOF_BIG_ENDIAN);
>                 if (ret)
> -                       goto err;
> +                       return ret;
>                 dev_dbg(&pdev->dev, "GPIO registers are LITTLE endian\n");
>         } else {
>                 ret = bgpio_init(gc, &pdev->dev, 4,
> @@ -342,7 +342,7 @@ static int mpc8xxx_probe(struct platform_device *pdev)
>                                  BGPIOF_BIG_ENDIAN
>                                  | BGPIOF_BIG_ENDIAN_BYTE_ORDER);
>                 if (ret)
> -                       goto err;
> +                       return ret;
>                 dev_dbg(&pdev->dev, "GPIO registers are BIG endian\n");
>         }
>
> @@ -384,7 +384,7 @@ static int mpc8xxx_probe(struct platform_device *pdev)
>         if (ret) {
>                 dev_err(&pdev->dev,
>                         "GPIO chip registration failed with status %d\n", ret);
> -               goto err;
> +               return ret;
>         }
>
>         mpc8xxx_gc->irqn = platform_get_irq(pdev, 0);
> @@ -416,9 +416,7 @@ static int mpc8xxx_probe(struct platform_device *pdev)
>
>         return 0;
>  err:
> -       if (mpc8xxx_gc->irq)
> -               irq_domain_remove(mpc8xxx_gc->irq);
> -       iounmap(mpc8xxx_gc->regs);
> +       irq_domain_remove(mpc8xxx_gc->irq);
>         return ret;
>  }
>
> @@ -432,7 +430,6 @@ static int mpc8xxx_remove(struct platform_device *pdev)
>         }
>
>         gpiochip_remove(&mpc8xxx_gc->gc);
> -       iounmap(mpc8xxx_gc->regs);
>
>         return 0;
>  }
> --
> 2.30.2
>

Applied, thanks!

Bart

  reply	other threads:[~2021-08-31 10:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-20 15:37 [PATCH 0/3] gpio: mpc8xxx: Fix 3 errors related to the error handling path of the 'mpc8xxx_probe()' Christophe JAILLET
2021-08-20 15:37 ` [PATCH 1/3] gpio: mpc8xxx: Fix a resources leak in the error handling path of 'mpc8xxx_probe()' Christophe JAILLET
2021-08-31 10:10   ` Bartosz Golaszewski
2021-08-20 15:38 ` [PATCH 2/3] gpio: mpc8xxx: Fix a potential double iounmap call in 'mpc8xxx_probe()' Christophe JAILLET
2021-08-31 10:10   ` Bartosz Golaszewski [this message]
2021-08-20 15:38 ` [PATCH 3/3] gpio: mpc8xxx: Use 'devm_gpiochip_add_data()' to simplify the code and avoid a leak Christophe JAILLET
2021-08-31 10:11   ` Bartosz Golaszewski
2021-08-23  8:06 ` [PATCH 0/3] gpio: mpc8xxx: Fix 3 errors related to the error handling path of the 'mpc8xxx_probe()' Bartosz Golaszewski

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='CAMpxmJX+diO-d-0sxFheMyPYJGxun6QOzddP-hrnU=ac2hSCKw@mail.gmail.com' \
    --to=bgolaszewski@baylibre.com \
    --cc=Laurentiu.Tudor@nxp.com \
    --cc=alexandru.marginean@nxp.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=hui.song_1@nxp.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ran.wang_1@nxp.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;
as well as URLs for NNTP newsgroup(s).