mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mukesh Ojha <mojha@codeaurora.org>
To: Geert Uytterhoeven <geert+renesas@glider.be>,
	Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>
Cc: Benoit Parrot <bparrot@ti.com>,
	Laxman Dewangan <ldewangan@nvidia.com>,
	Tomeu Vizoso <tomeu.vizoso@collabora.com>,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] gpio: of: Fix of_gpiochip_add() error path
Date: Thu, 28 Mar 2019 21:07:10 +0530	[thread overview]
Message-ID: <144289c1-4051-5a2f-3e8d-f1d5a44661c3@codeaurora.org> (raw)
In-Reply-To: <20190328131349.18838-2-geert+renesas@glider.be>


On 3/28/2019 6:43 PM, Geert Uytterhoeven wrote:
> If the call to of_gpiochip_scan_gpios() in of_gpiochip_add() fails, no
> error handling is performed.  This lead to the need of callers to call
> of_gpiochip_remove() on failure, which causes "BAD of_node_put() on ..."
> if the failure happened before the call to of_node_get().
>
> Fix this by adding proper error handling.
>
> Note that calling gpiochip_remove_pin_ranges() multiple times causes no
> harm: subsequent calls are a no-op.
>
> Fixes: dfbd379ba9b7431e ("gpio: of: Return error if gpio hog configuration failed")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>


Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>

-Mukesh

> ---
>   drivers/gpio/gpiolib-of.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
> index 8b9c3ab70f6eade4..257be7bac032a855 100644
> --- a/drivers/gpio/gpiolib-of.c
> +++ b/drivers/gpio/gpiolib-of.c
> @@ -717,7 +717,13 @@ int of_gpiochip_add(struct gpio_chip *chip)
>   
>   	of_node_get(chip->of_node);
>   
> -	return of_gpiochip_scan_gpios(chip);
> +	status = of_gpiochip_scan_gpios(chip);
> +	if (status) {
> +		of_node_put(chip->of_node);
> +		gpiochip_remove_pin_ranges(chip);
> +	}
> +
> +	return status;
>   }
>   
>   void of_gpiochip_remove(struct gpio_chip *chip)

  reply	other threads:[~2019-03-28 15:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-28 13:13 [PATCH 0/3] gpio: Failure path fixes Geert Uytterhoeven
2019-03-28 13:13 ` [PATCH 1/3] gpio: of: Fix of_gpiochip_add() error path Geert Uytterhoeven
2019-03-28 15:37   ` Mukesh Ojha [this message]
2019-03-28 16:58   ` Linus Walleij
2019-03-28 13:13 ` [PATCH 2/3] gpio: Fix gpiochip_add_data_with_key() " Geert Uytterhoeven
2019-03-28 15:31   ` Mukesh Ojha
2019-03-28 18:20     ` Geert Uytterhoeven
2019-03-28 17:03   ` Linus Walleij
2019-03-28 13:13 ` [PATCH 3/3] gpio: Remove obsolete comment about gpiochip_free_hogs() usage Geert Uytterhoeven
2019-03-28 15:01   ` Mukesh Ojha
2019-03-28 17:00   ` Linus Walleij

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=144289c1-4051-5a2f-3e8d-f1d5a44661c3@codeaurora.org \
    --to=mojha@codeaurora.org \
    --cc=bgolaszewski@baylibre.com \
    --cc=bparrot@ti.com \
    --cc=geert+renesas@glider.be \
    --cc=ldewangan@nvidia.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tomeu.vizoso@collabora.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®