linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] gpio: of: add missing of_node_put() in of_gpiochip_scan_gpios()
@ 2016-10-29 16:13 Wei Yongjun
  2016-10-29 18:14 ` Vladimir Zapolskiy
  2016-10-31  8:23 ` Linus Walleij
  0 siblings, 2 replies; 3+ messages in thread
From: Wei Yongjun @ 2016-10-29 16:13 UTC (permalink / raw)
  To: Linus Walleij, Alexandre Courbot; +Cc: Wei Yongjun, linux-gpio

From: Wei Yongjun <weiyongjun1@huawei.com>

When terminating for_each_available_child_of_node() iteration
with break or return, of_node_put() should be used to prevent
stale device node references from being left behind.

This is detected by Coccinelle semantic patch.

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/gpio/gpiolib-of.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index b46be18..92b185f 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -251,8 +251,10 @@ static int of_gpiochip_scan_gpios(struct gpio_chip *chip)
 			continue;
 
 		ret = gpiod_hog(desc, name, lflags, dflags);
-		if (ret < 0)
+		if (ret < 0) {
+			of_node_put(np);
 			return ret;
+		}
 	}
 
 	return 0;


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] gpio: of: add missing of_node_put() in of_gpiochip_scan_gpios()
  2016-10-29 16:13 [PATCH -next] gpio: of: add missing of_node_put() in of_gpiochip_scan_gpios() Wei Yongjun
@ 2016-10-29 18:14 ` Vladimir Zapolskiy
  2016-10-31  8:23 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Vladimir Zapolskiy @ 2016-10-29 18:14 UTC (permalink / raw)
  To: Wei Yongjun, Linus Walleij, Alexandre Courbot; +Cc: Wei Yongjun, linux-gpio

On 10/29/2016 07:13 PM, Wei Yongjun wrote:
> From: Wei Yongjun <weiyongjun1@huawei.com>
>
> When terminating for_each_available_child_of_node() iteration
> with break or return, of_node_put() should be used to prevent
> stale device node references from being left behind.
>
> This is detected by Coccinelle semantic patch.
>
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Reviewed-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>

> ---
>  drivers/gpio/gpiolib-of.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
> index b46be18..92b185f 100644
> --- a/drivers/gpio/gpiolib-of.c
> +++ b/drivers/gpio/gpiolib-of.c
> @@ -251,8 +251,10 @@ static int of_gpiochip_scan_gpios(struct gpio_chip *chip)
>  			continue;
>
>  		ret = gpiod_hog(desc, name, lflags, dflags);
> -		if (ret < 0)
> +		if (ret < 0) {
> +			of_node_put(np);
>  			return ret;
> +		}
>  	}
>
>  	return 0;
>
--
With best wishes,
Vladimir

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] gpio: of: add missing of_node_put() in of_gpiochip_scan_gpios()
  2016-10-29 16:13 [PATCH -next] gpio: of: add missing of_node_put() in of_gpiochip_scan_gpios() Wei Yongjun
  2016-10-29 18:14 ` Vladimir Zapolskiy
@ 2016-10-31  8:23 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2016-10-31  8:23 UTC (permalink / raw)
  To: Wei Yongjun; +Cc: Alexandre Courbot, Wei Yongjun, linux-gpio@vger.kernel.org

On Sat, Oct 29, 2016 at 6:13 PM, Wei Yongjun <weiyj.lk@gmail.com> wrote:

> From: Wei Yongjun <weiyongjun1@huawei.com>
>
> When terminating for_each_available_child_of_node() iteration
> with break or return, of_node_put() should be used to prevent
> stale device node references from being left behind.
>
> This is detected by Coccinelle semantic patch.
>
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Patch applied with Vladimir's review tag.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-10-31  8:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-29 16:13 [PATCH -next] gpio: of: add missing of_node_put() in of_gpiochip_scan_gpios() Wei Yongjun
2016-10-29 18:14 ` Vladimir Zapolskiy
2016-10-31  8:23 ` Linus Walleij

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).