linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] add missing of_node_put
@ 2018-05-23 19:07 Julia Lawall
  2018-05-23 19:07 ` [PATCH 1/5] pinctrl: at91-pio4: " Julia Lawall
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Julia Lawall @ 2018-05-23 19:07 UTC (permalink / raw)
  To: linux-pci
  Cc: kernel-janitors, linuxppc-dev, linux-kernel, linux-arm-kernel,
	linux-gpio, dri-devel, linux-rockchip

The device node iterators perform an of_node_get on each iteration, so a
jump out of the loop requires an of_node_put.

---

 drivers/gpu/drm/rockchip/rockchip_lvds.c   |    4 +++-
 drivers/pci/hotplug/pnv_php.c              |    8 ++++++--
 drivers/phy/hisilicon/phy-hisi-inno-usb2.c |    9 +++++++--
 drivers/pinctrl/pinctrl-at91-pio4.c        |    4 +++-
 drivers/soc/ti/knav_dma.c                  |    1 +
 5 files changed, 20 insertions(+), 6 deletions(-)

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

* [PATCH 1/5] pinctrl: at91-pio4: add missing of_node_put
  2018-05-23 19:07 [PATCH 0/5] add missing of_node_put Julia Lawall
@ 2018-05-23 19:07 ` Julia Lawall
  2018-05-24  7:59   ` Ludovic Desroches
  2018-05-24  8:30   ` Linus Walleij
  2018-05-23 19:07 ` [PATCH 2/5] phy: " Julia Lawall
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 10+ messages in thread
From: Julia Lawall @ 2018-05-23 19:07 UTC (permalink / raw)
  To: Ludovic Desroches
  Cc: kernel-janitors, Linus Walleij, Nicolas Ferre, Alexandre Belloni,
	linux-arm-kernel, linux-gpio, linux-kernel

The device node iterators perform an of_node_get on each iteration, so a
jump out of the loop requires an of_node_put.

The semantic patch that fixes this problem is as follows
(http://coccinelle.lip6.fr):

// <smpl>
@@
expression root,e;
local idexpression child;
iterator name for_each_child_of_node;
@@

 for_each_child_of_node(root, child) {
   ... when != of_node_put(child)
       when != e = child
+  of_node_put(child);
?  break;
   ...
}
... when != child
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/pinctrl/pinctrl-at91-pio4.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c
index 4b57a13..bafb3d4 100644
--- a/drivers/pinctrl/pinctrl-at91-pio4.c
+++ b/drivers/pinctrl/pinctrl-at91-pio4.c
@@ -576,8 +576,10 @@ static int atmel_pctl_dt_node_to_map(struct pinctrl_dev *pctldev,
 		for_each_child_of_node(np_config, np) {
 			ret = atmel_pctl_dt_subnode_to_map(pctldev, np, map,
 						    &reserved_maps, num_maps);
-			if (ret < 0)
+			if (ret < 0) {
+				of_node_put(np);
 				break;
+			}
 		}
 	}
 

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

* [PATCH 2/5] phy: add missing of_node_put
  2018-05-23 19:07 [PATCH 0/5] add missing of_node_put Julia Lawall
  2018-05-23 19:07 ` [PATCH 1/5] pinctrl: at91-pio4: " Julia Lawall
@ 2018-05-23 19:07 ` Julia Lawall
  2018-05-23 19:07 ` [PATCH 3/5] soc: ti: knav_dma: " Julia Lawall
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Julia Lawall @ 2018-05-23 19:07 UTC (permalink / raw)
  To: Kishon Vijay Abraham I; +Cc: kernel-janitors, linux-kernel

The device node iterators perform an of_node_get on each iteration, so a
jump out of the loop requires an of_node_put.

The semantic patch that fixes this problem in the break case is as follows
(http://coccinelle.lip6.fr):

// <smpl>
@@
expression root,e;
local idexpression child;
iterator name for_each_child_of_node;
@@

 for_each_child_of_node(root, child) {
   ... when != of_node_put(child)
       when != e = child
+  of_node_put(child);
?  break;
   ...
}
... when != child
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/phy/hisilicon/phy-hisi-inno-usb2.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/hisilicon/phy-hisi-inno-usb2.c b/drivers/phy/hisilicon/phy-hisi-inno-usb2.c
index 5243812..0da14b6 100644
--- a/drivers/phy/hisilicon/phy-hisi-inno-usb2.c
+++ b/drivers/phy/hisilicon/phy-hisi-inno-usb2.c
@@ -154,14 +154,18 @@ static int hisi_inno_phy_probe(struct platform_device *pdev)
 		struct phy *phy;
 
 		rst = of_reset_control_get_exclusive(child, NULL);
-		if (IS_ERR(rst))
+		if (IS_ERR(rst)) {
+			of_node_put(child);
 			return PTR_ERR(rst);
+		}
 		priv->ports[i].utmi_rst = rst;
 		priv->ports[i].priv = priv;
 
 		phy = devm_phy_create(dev, child, &hisi_inno_phy_ops);
-		if (IS_ERR(phy))
+		if (IS_ERR(phy)) {
+			of_node_put(child);
 			return PTR_ERR(phy);
+		}
 
 		phy_set_bus_width(phy, 8);
 		phy_set_drvdata(phy, &priv->ports[i]);
@@ -169,6 +173,7 @@ static int hisi_inno_phy_probe(struct platform_device *pdev)
 
 		if (i > INNO_PHY_PORT_NUM) {
 			dev_warn(dev, "Support %d ports in maximum\n", i);
+			of_node_put(child);
 			break;
 		}
 	}

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

* [PATCH 3/5] soc: ti: knav_dma: add missing of_node_put
  2018-05-23 19:07 [PATCH 0/5] add missing of_node_put Julia Lawall
  2018-05-23 19:07 ` [PATCH 1/5] pinctrl: at91-pio4: " Julia Lawall
  2018-05-23 19:07 ` [PATCH 2/5] phy: " Julia Lawall
@ 2018-05-23 19:07 ` Julia Lawall
  2018-05-23 19:07 ` [PATCH 4/5] pci/hotplug/pnv-php: " Julia Lawall
  2018-05-23 19:07 ` [PATCH 5/5] drm/rockchip: lvds: " Julia Lawall
  4 siblings, 0 replies; 10+ messages in thread
From: Julia Lawall @ 2018-05-23 19:07 UTC (permalink / raw)
  To: Santosh Shilimkar; +Cc: kernel-janitors, linux-kernel, linux-arm-kernel

The device node iterators perform an of_node_get on each iteration, so a
jump out of the loop requires an of_node_put.

The semantic patch that fixes this problem is as follows
(http://coccinelle.lip6.fr):

// <smpl>
@@
expression root,e;
local idexpression child;
iterator name for_each_child_of_node;
@@

 for_each_child_of_node(root, child) {
   ... when != of_node_put(child)
       when != e = child
+  of_node_put(child);
?  break;
   ...
}
... when != child
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/soc/ti/knav_dma.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/soc/ti/knav_dma.c b/drivers/soc/ti/knav_dma.c
index 224d7dd..bda3173 100644
--- a/drivers/soc/ti/knav_dma.c
+++ b/drivers/soc/ti/knav_dma.c
@@ -768,6 +768,7 @@ static int knav_dma_probe(struct platform_device *pdev)
 		ret = dma_init(node, child);
 		if (ret) {
 			dev_err(&pdev->dev, "init failed with %d\n", ret);
+			of_node_put(child);
 			break;
 		}
 	}

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

* [PATCH 4/5] pci/hotplug/pnv-php: add missing of_node_put
  2018-05-23 19:07 [PATCH 0/5] add missing of_node_put Julia Lawall
                   ` (2 preceding siblings ...)
  2018-05-23 19:07 ` [PATCH 3/5] soc: ti: knav_dma: " Julia Lawall
@ 2018-05-23 19:07 ` Julia Lawall
  2018-05-23 21:50   ` Bjorn Helgaas
  2018-05-23 19:07 ` [PATCH 5/5] drm/rockchip: lvds: " Julia Lawall
  4 siblings, 1 reply; 10+ messages in thread
From: Julia Lawall @ 2018-05-23 19:07 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: kernel-janitors, Paul Mackerras, Michael Ellerman, Bjorn Helgaas,
	linuxppc-dev, linux-pci, linux-kernel

The device node iterators perform an of_node_get on each iteration, so a
jump out of the loop requires an of_node_put.

The semantic patch that fixes this problem is as follows
(http://coccinelle.lip6.fr):

// <smpl>
@@
expression root,e;
local idexpression child;
iterator name for_each_child_of_node;
@@

 for_each_child_of_node(root, child) {
   ... when != of_node_put(child)
       when != e = child
+  of_node_put(child);
?  break;
   ...
}
... when != child
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/pci/hotplug/pnv_php.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/hotplug/pnv_php.c b/drivers/pci/hotplug/pnv_php.c
index d441006..6c2e8d7 100644
--- a/drivers/pci/hotplug/pnv_php.c
+++ b/drivers/pci/hotplug/pnv_php.c
@@ -220,12 +220,16 @@ static int pnv_php_populate_changeset(struct of_changeset *ocs,
 
 	for_each_child_of_node(dn, child) {
 		ret = of_changeset_attach_node(ocs, child);
-		if (ret)
+		if (ret) {
+			of_node_put(child);
 			break;
+		}
 
 		ret = pnv_php_populate_changeset(ocs, child);
-		if (ret)
+		if (ret) {
+			of_node_put(child);
 			break;
+		}
 	}
 
 	return ret;

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

* [PATCH 5/5] drm/rockchip: lvds: add missing of_node_put
  2018-05-23 19:07 [PATCH 0/5] add missing of_node_put Julia Lawall
                   ` (3 preceding siblings ...)
  2018-05-23 19:07 ` [PATCH 4/5] pci/hotplug/pnv-php: " Julia Lawall
@ 2018-05-23 19:07 ` Julia Lawall
  2018-06-16 12:24   ` Heiko Stübner
  4 siblings, 1 reply; 10+ messages in thread
From: Julia Lawall @ 2018-05-23 19:07 UTC (permalink / raw)
  To: Sandy Huang
  Cc: kernel-janitors, Heiko Stübner, David Airlie, dri-devel,
	linux-arm-kernel, linux-rockchip, linux-kernel

The device node iterators perform an of_node_get on each iteration, so a
jump out of the loop requires an of_node_put.

The semantic patch that fixes this problem is as follows
(http://coccinelle.lip6.fr):

// <smpl>
@@
expression root,e;
local idexpression child;
iterator name for_each_child_of_node;
@@

 for_each_child_of_node(root, child) {
   ... when != of_node_put(child)
       when != e = child
+  of_node_put(child);
?  break;
   ...
}
... when != child
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/gpu/drm/rockchip/rockchip_lvds.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_lvds.c b/drivers/gpu/drm/rockchip/rockchip_lvds.c
index e67f4ea..051b8be 100644
--- a/drivers/gpu/drm/rockchip/rockchip_lvds.c
+++ b/drivers/gpu/drm/rockchip/rockchip_lvds.c
@@ -363,8 +363,10 @@ static int rockchip_lvds_bind(struct device *dev, struct device *master,
 		of_property_read_u32(endpoint, "reg", &endpoint_id);
 		ret = drm_of_find_panel_or_bridge(dev->of_node, 1, endpoint_id,
 						  &lvds->panel, &lvds->bridge);
-		if (!ret)
+		if (!ret) {
+			of_node_put(endpoint);
 			break;
+		}
 	}
 	if (!child_count) {
 		DRM_DEV_ERROR(dev, "lvds port does not have any children\n");

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

* Re: [PATCH 4/5] pci/hotplug/pnv-php: add missing of_node_put
  2018-05-23 19:07 ` [PATCH 4/5] pci/hotplug/pnv-php: " Julia Lawall
@ 2018-05-23 21:50   ` Bjorn Helgaas
  0 siblings, 0 replies; 10+ messages in thread
From: Bjorn Helgaas @ 2018-05-23 21:50 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Benjamin Herrenschmidt, kernel-janitors, Paul Mackerras,
	Michael Ellerman, Bjorn Helgaas, linuxppc-dev, linux-pci,
	linux-kernel

On Wed, May 23, 2018 at 09:07:15PM +0200, Julia Lawall wrote:
> The device node iterators perform an of_node_get on each iteration, so a
> jump out of the loop requires an of_node_put.
> 
> The semantic patch that fixes this problem is as follows
> (http://coccinelle.lip6.fr):
> 
> // <smpl>
> @@
> expression root,e;
> local idexpression child;
> iterator name for_each_child_of_node;
> @@
> 
>  for_each_child_of_node(root, child) {
>    ... when != of_node_put(child)
>        when != e = child
> +  of_node_put(child);
> ?  break;
>    ...
> }
> ... when != child
> // </smpl>
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

Applied to pci/hotplug for v4.18, thanks!

> ---
>  drivers/pci/hotplug/pnv_php.c |    8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/hotplug/pnv_php.c b/drivers/pci/hotplug/pnv_php.c
> index d441006..6c2e8d7 100644
> --- a/drivers/pci/hotplug/pnv_php.c
> +++ b/drivers/pci/hotplug/pnv_php.c
> @@ -220,12 +220,16 @@ static int pnv_php_populate_changeset(struct of_changeset *ocs,
>  
>  	for_each_child_of_node(dn, child) {
>  		ret = of_changeset_attach_node(ocs, child);
> -		if (ret)
> +		if (ret) {
> +			of_node_put(child);
>  			break;
> +		}
>  
>  		ret = pnv_php_populate_changeset(ocs, child);
> -		if (ret)
> +		if (ret) {
> +			of_node_put(child);
>  			break;
> +		}
>  	}
>  
>  	return ret;
> 

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

* Re: [PATCH 1/5] pinctrl: at91-pio4: add missing of_node_put
  2018-05-23 19:07 ` [PATCH 1/5] pinctrl: at91-pio4: " Julia Lawall
@ 2018-05-24  7:59   ` Ludovic Desroches
  2018-05-24  8:30   ` Linus Walleij
  1 sibling, 0 replies; 10+ messages in thread
From: Ludovic Desroches @ 2018-05-24  7:59 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Ludovic Desroches, kernel-janitors, Linus Walleij, Nicolas Ferre,
	Alexandre Belloni, linux-arm-kernel, linux-gpio, linux-kernel

On Wed, May 23, 2018 at 09:07:12PM +0200, Julia Lawall wrote:
> The device node iterators perform an of_node_get on each iteration, so a
> jump out of the loop requires an of_node_put.
> 
> The semantic patch that fixes this problem is as follows
> (http://coccinelle.lip6.fr):
> 
> // <smpl>
> @@
> expression root,e;
> local idexpression child;
> iterator name for_each_child_of_node;
> @@
> 
>  for_each_child_of_node(root, child) {
>    ... when != of_node_put(child)
>        when != e = child
> +  of_node_put(child);
> ?  break;
>    ...
> }
> ... when != child
> // </smpl>
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>

Thanks
> 
> ---
>  drivers/pinctrl/pinctrl-at91-pio4.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c
> index 4b57a13..bafb3d4 100644
> --- a/drivers/pinctrl/pinctrl-at91-pio4.c
> +++ b/drivers/pinctrl/pinctrl-at91-pio4.c
> @@ -576,8 +576,10 @@ static int atmel_pctl_dt_node_to_map(struct pinctrl_dev *pctldev,
>  		for_each_child_of_node(np_config, np) {
>  			ret = atmel_pctl_dt_subnode_to_map(pctldev, np, map,
>  						    &reserved_maps, num_maps);
> -			if (ret < 0)
> +			if (ret < 0) {
> +				of_node_put(np);
>  				break;
> +			}
>  		}
>  	}
>  
> 

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

* Re: [PATCH 1/5] pinctrl: at91-pio4: add missing of_node_put
  2018-05-23 19:07 ` [PATCH 1/5] pinctrl: at91-pio4: " Julia Lawall
  2018-05-24  7:59   ` Ludovic Desroches
@ 2018-05-24  8:30   ` Linus Walleij
  1 sibling, 0 replies; 10+ messages in thread
From: Linus Walleij @ 2018-05-24  8:30 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Ludovic Desroches, kernel-janitors, Nicolas Ferre,
	Alexandre Belloni, Linux ARM, open list:GPIO SUBSYSTEM,
	linux-kernel

On Wed, May 23, 2018 at 9:07 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:

> The device node iterators perform an of_node_get on each iteration, so a
> jump out of the loop requires an of_node_put.
>
> The semantic patch that fixes this problem is as follows
> (http://coccinelle.lip6.fr):
>
> // <smpl>
> @@
> expression root,e;
> local idexpression child;
> iterator name for_each_child_of_node;
> @@
>
>  for_each_child_of_node(root, child) {
>    ... when != of_node_put(child)
>        when != e = child
> +  of_node_put(child);
> ?  break;
>    ...
> }
> ... when != child
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

Patch applied with Ludovic's ACK!

Yours,
Linus Walleij

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

* Re: [PATCH 5/5] drm/rockchip: lvds: add missing of_node_put
  2018-05-23 19:07 ` [PATCH 5/5] drm/rockchip: lvds: " Julia Lawall
@ 2018-06-16 12:24   ` Heiko Stübner
  0 siblings, 0 replies; 10+ messages in thread
From: Heiko Stübner @ 2018-06-16 12:24 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Sandy Huang, kernel-janitors, David Airlie, dri-devel,
	linux-arm-kernel, linux-rockchip, linux-kernel

Hi Julia,

Am Mittwoch, 23. Mai 2018, 21:07:16 CEST schrieb Julia Lawall:
> The device node iterators perform an of_node_get on each iteration, so a
> jump out of the loop requires an of_node_put.
> 
> The semantic patch that fixes this problem is as follows
> (http://coccinelle.lip6.fr):
> 
> // <smpl>
> @@
> expression root,e;
> local idexpression child;
> iterator name for_each_child_of_node;
> @@
> 
>  for_each_child_of_node(root, child) {
>    ... when != of_node_put(child)
>        when != e = child
> +  of_node_put(child);
> ?  break;
>    ...
> }
> ... when != child
> // </smpl>
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

thanks for catching this. I've added a "Fixes"-tag and
applied the patch to drm-misc-next 


Thanks
Heiko



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

end of thread, other threads:[~2018-06-16 12:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-23 19:07 [PATCH 0/5] add missing of_node_put Julia Lawall
2018-05-23 19:07 ` [PATCH 1/5] pinctrl: at91-pio4: " Julia Lawall
2018-05-24  7:59   ` Ludovic Desroches
2018-05-24  8:30   ` Linus Walleij
2018-05-23 19:07 ` [PATCH 2/5] phy: " Julia Lawall
2018-05-23 19:07 ` [PATCH 3/5] soc: ti: knav_dma: " Julia Lawall
2018-05-23 19:07 ` [PATCH 4/5] pci/hotplug/pnv-php: " Julia Lawall
2018-05-23 21:50   ` Bjorn Helgaas
2018-05-23 19:07 ` [PATCH 5/5] drm/rockchip: lvds: " Julia Lawall
2018-06-16 12:24   ` Heiko Stübner

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