linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] add missing of_node_put
@ 2015-10-25 13:56 Julia Lawall
  2015-10-25 13:57 ` [PATCH 1/8] net: thunderx: " Julia Lawall
                   ` (8 more replies)
  0 siblings, 9 replies; 12+ messages in thread
From: Julia Lawall @ 2015-10-25 13:56 UTC (permalink / raw)
  To: linux-wireless
  Cc: kernel-janitors, netdev, linux-arm-kernel, linux-kernel,
	Sören Brinkmann, linux-media, Russell King - ARM Linux,
	Thomas Petazzoni, Andrew Lunn, Bjorn Helgaas, Jason Cooper

The various for_each device_node iterators performs an of_node_get on each
iteration, so a break out of the loop requires an of_node_put.

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

// <smpl>
@r@
local idexpression n;
expression e1,e2;
iterator name for_each_node_by_name, for_each_node_by_type,
for_each_compatible_node, for_each_matching_node,
for_each_matching_node_and_match, for_each_child_of_node,
for_each_available_child_of_node, for_each_node_with_property;
iterator i;
statement S;
expression list [n1] es;
@@

(
(
for_each_node_by_name(n,e1) S
|
for_each_node_by_type(n,e1) S
|
for_each_compatible_node(n,e1,e2) S
|
for_each_matching_node(n,e1) S
|
for_each_matching_node_and_match(n,e1,e2) S
|
for_each_child_of_node(e1,n) S
|
for_each_available_child_of_node(e1,n) S
|
for_each_node_with_property(n,e1) S
)
&
i(es,n,...) S
)

@@
local idexpression r.n;
iterator r.i;
expression e;
expression list [r.n1] es;
@@

 i(es,n,...) {
   ...
(
   of_node_put(n);
|
   e = n
|
   return n;
|
+  of_node_put(n);
?  return ...;
)
   ...
 }

@@
local idexpression r.n;
iterator r.i;
expression e;
expression list [r.n1] es;
@@

 i(es,n,...) {
   ...
(
   of_node_put(n);
|
   e = n
|
+  of_node_put(n);
?  break;
)
   ...
 }
... when != n

@@
local idexpression r.n;
iterator r.i;
expression e;
identifier l;
expression list [r.n1] es;
@@

 i(es,n,...) {
   ...
(
   of_node_put(n);
|
   e = n
|
+  of_node_put(n);
?  goto l;
)
   ...
 }
...
l: ... when != n// </smpl>

---

 drivers/media/platform/xilinx/xilinx-tpg.c        |    2 ++
 drivers/media/platform/xilinx/xilinx-vipp.c       |    4 +++-
 drivers/net/ethernet/cavium/thunder/thunder_bgx.c |    4 +++-
 drivers/net/ethernet/marvell/mv643xx_eth.c        |    4 +++-
 drivers/net/ethernet/ti/netcp_ethss.c             |    8 ++++++--
 drivers/net/phy/mdio-mux-mmioreg.c                |    2 ++
 drivers/net/phy/mdio-mux.c                        |    1 +
 drivers/net/wireless/ath/ath6kl/init.c            |    1 +
 8 files changed, 21 insertions(+), 5 deletions(-)

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

* [PATCH 1/8] net: thunderx: add missing of_node_put
  2015-10-25 13:56 [PATCH 0/8] add missing of_node_put Julia Lawall
@ 2015-10-25 13:57 ` Julia Lawall
  2015-10-25 13:57 ` [PATCH 2/8] net: netcp: " Julia Lawall
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2015-10-25 13:57 UTC (permalink / raw)
  To: Sunil Goutham
  Cc: kernel-janitors, Robert Richter, linux-arm-kernel, netdev,
	linux-kernel, Russell King - ARM Linux, Thomas Petazzoni,
	Andrew Lunn, Bjorn Helgaas, Jason Cooper

for_each_child_of_node performs an of_node_get on each iteration, so
a break out of the loop requires an of_node_put.

A simplified version of the semantic patch that fixes this problem is as
follows (http://coccinelle.lip6.fr):

// <smpl>
@@
local idexpression r.n;
expression r,e;
@@

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

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

---
 drivers/net/ethernet/cavium/thunder/thunder_bgx.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
index 574c492..180aa9f 100644
--- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
@@ -977,8 +977,10 @@ static int bgx_init_of_phy(struct bgx *bgx)
 		SET_NETDEV_DEV(&bgx->lmac[lmac].netdev, &bgx->pdev->dev);
 		bgx->lmac[lmac].lmacid = lmac;
 		lmac++;
-		if (lmac == MAX_LMAC_PER_BGX)
+		if (lmac == MAX_LMAC_PER_BGX) {
+			of_node_put(np_child);
 			break;
+		}
 	}
 	return 0;
 }


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

* [PATCH 2/8] net: netcp: add missing of_node_put
  2015-10-25 13:56 [PATCH 0/8] add missing of_node_put Julia Lawall
  2015-10-25 13:57 ` [PATCH 1/8] net: thunderx: " Julia Lawall
@ 2015-10-25 13:57 ` Julia Lawall
  2015-10-25 13:57 ` [PATCH 3/8] netdev/phy: " Julia Lawall
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2015-10-25 13:57 UTC (permalink / raw)
  To: Wingman Kwok
  Cc: kernel-janitors, Murali Karicheri, netdev, linux-kernel,
	Russell King - ARM Linux, Thomas Petazzoni, Andrew Lunn,
	Bjorn Helgaas, Jason Cooper

for_each_child_of_node performs an of_node_get on each iteration, so
a break out of the loop requires an of_node_put.

A simplified version of the semantic patch that fixes this problem is as
follows (http://coccinelle.lip6.fr):

// <smpl>
@@
local idexpression r.n;
expression r,e;
@@

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

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

---
 drivers/net/ethernet/ti/netcp_ethss.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index 6bff8d8..4e70e75 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -2637,8 +2637,10 @@ static void init_secondary_ports(struct gbe_priv *gbe_dev,
 			mac_phy_link = true;
 
 		slave->open = true;
-		if (gbe_dev->num_slaves >= gbe_dev->max_num_slaves)
+		if (gbe_dev->num_slaves >= gbe_dev->max_num_slaves) {
+			of_node_put(port);
 			break;
+		}
 	}
 
 	/* of_phy_connect() is needed only for MAC-PHY interface */
@@ -3137,8 +3139,10 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev,
 			continue;
 		}
 		gbe_dev->num_slaves++;
-		if (gbe_dev->num_slaves >= gbe_dev->max_num_slaves)
+		if (gbe_dev->num_slaves >= gbe_dev->max_num_slaves) {
+			of_node_put(interface);
 			break;
+		}
 	}
 	of_node_put(interfaces);
 


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

* [PATCH 3/8] netdev/phy: add missing of_node_put
  2015-10-25 13:56 [PATCH 0/8] add missing of_node_put Julia Lawall
  2015-10-25 13:57 ` [PATCH 1/8] net: thunderx: " Julia Lawall
  2015-10-25 13:57 ` [PATCH 2/8] net: netcp: " Julia Lawall
@ 2015-10-25 13:57 ` Julia Lawall
  2015-10-25 13:57 ` [PATCH 4/8] net: phy: mdio: " Julia Lawall
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2015-10-25 13:57 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: kernel-janitors, netdev, linux-kernel, Russell King - ARM Linux,
	Thomas Petazzoni, Andrew Lunn, Bjorn Helgaas, Jason Cooper

for_each_available_child_of_node performs an of_node_get on each iteration, so
a break out of the loop requires an of_node_put.

A simplified version of the semantic patch that fixes this problem is as
follows (http://coccinelle.lip6.fr):

// <smpl>
@@
local idexpression r.n;
expression r,e;
@@

 for_each_available_child_of_node(r,n) {
   ...
(
   of_node_put(n);
|
   e = n
|
+  of_node_put(n);
?  break;
)
   ...
 }
... when != n
// </smpl>

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

---
 drivers/net/phy/mdio-mux.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/phy/mdio-mux.c b/drivers/net/phy/mdio-mux.c
index 280c7c3..908e8d4 100644
--- a/drivers/net/phy/mdio-mux.c
+++ b/drivers/net/phy/mdio-mux.c
@@ -144,6 +144,7 @@ int mdio_mux_init(struct device *dev,
 			dev_err(dev,
 				"Error: Failed to allocate memory for child\n");
 			ret_val = -ENOMEM;
+			of_node_put(child_bus_node);
 			break;
 		}
 		cb->bus_number = v;


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

* [PATCH 4/8] net: phy: mdio: add missing of_node_put
  2015-10-25 13:56 [PATCH 0/8] add missing of_node_put Julia Lawall
                   ` (2 preceding siblings ...)
  2015-10-25 13:57 ` [PATCH 3/8] netdev/phy: " Julia Lawall
@ 2015-10-25 13:57 ` Julia Lawall
  2015-10-25 13:57 ` [PATCH 5/8] [media] v4l: xilinx-vipp: " Julia Lawall
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2015-10-25 13:57 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: kernel-janitors, netdev, linux-kernel, Russell King - ARM Linux,
	Thomas Petazzoni, Andrew Lunn, Bjorn Helgaas, Jason Cooper

for_each_available_child_of_node performs an of_node_get on each iteration, so
a break out of the loop requires an of_node_put.

A simplified version of the semantic patch that fixes this problem is as
follows (http://coccinelle.lip6.fr):

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

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

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

---
 drivers/net/phy/mdio-mux-mmioreg.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/phy/mdio-mux-mmioreg.c b/drivers/net/phy/mdio-mux-mmioreg.c
index 2377c13..7fde454 100644
--- a/drivers/net/phy/mdio-mux-mmioreg.c
+++ b/drivers/net/phy/mdio-mux-mmioreg.c
@@ -113,12 +113,14 @@ static int mdio_mux_mmioreg_probe(struct platform_device *pdev)
 		if (!iprop || len != sizeof(uint32_t)) {
 			dev_err(&pdev->dev, "mdio-mux child node %s is "
 				"missing a 'reg' property\n", np2->full_name);
+			of_node_put(np2);
 			return -ENODEV;
 		}
 		if (be32_to_cpup(iprop) & ~s->mask) {
 			dev_err(&pdev->dev, "mdio-mux child node %s has "
 				"a 'reg' value with unmasked bits\n",
 				np2->full_name);
+			of_node_put(np2);
 			return -ENODEV;
 		}
 	}


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

* [PATCH 5/8] [media] v4l: xilinx-vipp: add missing of_node_put
  2015-10-25 13:56 [PATCH 0/8] add missing of_node_put Julia Lawall
                   ` (3 preceding siblings ...)
  2015-10-25 13:57 ` [PATCH 4/8] net: phy: mdio: " Julia Lawall
@ 2015-10-25 13:57 ` Julia Lawall
  2015-10-26  1:20   ` Laurent Pinchart
  2015-10-25 13:57 ` [PATCH 6/8] [media] v4l: xilinx-tpg: " Julia Lawall
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 12+ messages in thread
From: Julia Lawall @ 2015-10-25 13:57 UTC (permalink / raw)
  To: Hyun Kwon
  Cc: kernel-janitors, Laurent Pinchart, Mauro Carvalho Chehab,
	Michal Simek, Sören Brinkmann, linux-media,
	linux-arm-kernel, linux-kernel, Russell King - ARM Linux,
	Thomas Petazzoni, Andrew Lunn, Bjorn Helgaas, Jason Cooper

for_each_child_of_node performs an of_node_get on each iteration, so
a break out of the loop requires an of_node_put.

A simplified version of the semantic patch that fixes this problem is as
follows (http://coccinelle.lip6.fr):

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

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

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

---
 drivers/media/platform/xilinx/xilinx-vipp.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c
index 7b7cb9c..b9bf24f 100644
--- a/drivers/media/platform/xilinx/xilinx-vipp.c
+++ b/drivers/media/platform/xilinx/xilinx-vipp.c
@@ -476,8 +476,10 @@ static int xvip_graph_dma_init(struct xvip_composite_device *xdev)
 
 	for_each_child_of_node(ports, port) {
 		ret = xvip_graph_dma_init_one(xdev, port);
-		if (ret < 0)
+		if (ret < 0) {
+			of_node_put(port);
 			return ret;
+		}
 	}
 
 	return 0;


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

* [PATCH 6/8] [media] v4l: xilinx-tpg: add missing of_node_put
  2015-10-25 13:56 [PATCH 0/8] add missing of_node_put Julia Lawall
                   ` (4 preceding siblings ...)
  2015-10-25 13:57 ` [PATCH 5/8] [media] v4l: xilinx-vipp: " Julia Lawall
@ 2015-10-25 13:57 ` Julia Lawall
  2015-10-26  1:19   ` Laurent Pinchart
  2015-10-25 13:57 ` [PATCH 7/8] ath6kl: " Julia Lawall
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 12+ messages in thread
From: Julia Lawall @ 2015-10-25 13:57 UTC (permalink / raw)
  To: Hyun Kwon
  Cc: kernel-janitors, Laurent Pinchart, Mauro Carvalho Chehab,
	Michal Simek, Sören Brinkmann, linux-media,
	linux-arm-kernel, linux-kernel, Russell King - ARM Linux,
	Thomas Petazzoni, Andrew Lunn, Bjorn Helgaas, Jason Cooper

for_each_child_of_node performs an of_node_get on each iteration, so
a break out of the loop requires an of_node_put.

A simplified version of the semantic patch that fixes this problem is as
follows (http://coccinelle.lip6.fr):

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

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

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

---
 drivers/media/platform/xilinx/xilinx-tpg.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/platform/xilinx/xilinx-tpg.c b/drivers/media/platform/xilinx/xilinx-tpg.c
index b5f7d5e..8bd7e37 100644
--- a/drivers/media/platform/xilinx/xilinx-tpg.c
+++ b/drivers/media/platform/xilinx/xilinx-tpg.c
@@ -731,6 +731,7 @@ static int xtpg_parse_of(struct xtpg_device *xtpg)
 		format = xvip_of_get_format(port);
 		if (IS_ERR(format)) {
 			dev_err(dev, "invalid format in DT");
+			of_node_put(port);
 			return PTR_ERR(format);
 		}
 
@@ -739,6 +740,7 @@ static int xtpg_parse_of(struct xtpg_device *xtpg)
 			xtpg->vip_format = format;
 		} else if (xtpg->vip_format != format) {
 			dev_err(dev, "in/out format mismatch in DT");
+			of_node_put(port);
 			return -EINVAL;
 		}
 


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

* [PATCH 7/8] ath6kl: add missing of_node_put
  2015-10-25 13:56 [PATCH 0/8] add missing of_node_put Julia Lawall
                   ` (5 preceding siblings ...)
  2015-10-25 13:57 ` [PATCH 6/8] [media] v4l: xilinx-tpg: " Julia Lawall
@ 2015-10-25 13:57 ` Julia Lawall
  2015-10-25 13:57 ` [PATCH 8/8] net: mv643xx_eth: " Julia Lawall
  2015-10-27  5:08 ` [PATCH 0/8] " David Miller
  8 siblings, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2015-10-25 13:57 UTC (permalink / raw)
  To: Kalle Valo
  Cc: kernel-janitors, linux-wireless, netdev, linux-kernel,
	Russell King - ARM Linux, Thomas Petazzoni, Andrew Lunn,
	Bjorn Helgaas, Jason Cooper

for_each_compatible_node performs an of_node_get on each iteration, so
a break out of the loop requires an of_node_put.

A simplified version of the semantic patch that fixes this problem is as
follows (http://coccinelle.lip6.fr):

// <smpl>
@@
expression e;
local idexpression n;
@@

 for_each_compatible_node(n,...) {
   ... when != of_node_put(n)
       when != e = n
(
   return n;
|
+  of_node_put(n);
?  return ...;
)
   ...
 }
// </smpl>

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

---
 drivers/net/wireless/ath/ath6kl/init.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c
index 6e473fa..12241b1 100644
--- a/drivers/net/wireless/ath/ath6kl/init.c
+++ b/drivers/net/wireless/ath/ath6kl/init.c
@@ -715,6 +715,7 @@ static bool check_device_tree(struct ath6kl *ar)
 				   board_filename, ret);
 			continue;
 		}
+		of_node_put(node);
 		return true;
 	}
 	return false;


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

* [PATCH 8/8] net: mv643xx_eth: add missing of_node_put
  2015-10-25 13:56 [PATCH 0/8] add missing of_node_put Julia Lawall
                   ` (6 preceding siblings ...)
  2015-10-25 13:57 ` [PATCH 7/8] ath6kl: " Julia Lawall
@ 2015-10-25 13:57 ` Julia Lawall
  2015-10-27  5:08 ` [PATCH 0/8] " David Miller
  8 siblings, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2015-10-25 13:57 UTC (permalink / raw)
  To: Sebastian Hesselbarth
  Cc: kernel-janitors, netdev, linux-kernel, Russell King - ARM Linux,
	Thomas Petazzoni, Andrew Lunn, Bjorn Helgaas, Jason Cooper

for_each_available_child_of_node performs an of_node_get on each iteration, so
a break out of the loop requires an of_node_put.

A simplified version of the semantic patch that fixes this problem is as
follows (http://coccinelle.lip6.fr):

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

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

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

---
 drivers/net/ethernet/marvell/mv643xx_eth.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index 603d29d..18ea385 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -2785,8 +2785,10 @@ static int mv643xx_eth_shared_of_probe(struct platform_device *pdev)
 
 	for_each_available_child_of_node(np, pnp) {
 		ret = mv643xx_eth_shared_of_add_port(pdev, pnp);
-		if (ret)
+		if (ret) {
+			of_node_put(pnp);
 			return ret;
+		}
 	}
 	return 0;
 }


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

* Re: [PATCH 6/8] [media] v4l: xilinx-tpg: add missing of_node_put
  2015-10-25 13:57 ` [PATCH 6/8] [media] v4l: xilinx-tpg: " Julia Lawall
@ 2015-10-26  1:19   ` Laurent Pinchart
  0 siblings, 0 replies; 12+ messages in thread
From: Laurent Pinchart @ 2015-10-26  1:19 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Hyun Kwon, kernel-janitors, Mauro Carvalho Chehab, Michal Simek,
	Sören Brinkmann, linux-media, linux-arm-kernel,
	linux-kernel, Russell King - ARM Linux, Thomas Petazzoni,
	Andrew Lunn, Bjorn Helgaas, Jason Cooper

Hi Julia,

Thank you for the patch.

On Sunday 25 October 2015 14:57:05 Julia Lawall wrote:
> for_each_child_of_node performs an of_node_get on each iteration, so
> a break out of the loop requires an of_node_put.
> 
> A simplified version of the semantic patch that fixes this problem is as
> follows (http://coccinelle.lip6.fr):
> 
> // <smpl>
> @@
> expression root,e;
> local idexpression child;
> @@
> 
>  for_each_child_of_node(root, child) {
>    ... when != of_node_put(child)
>        when != e = child
> (
>    return child;
> 
> +  of_node_put(child);
> ?  return ...;
> )
>    ...
>  }
> // </smpl>
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/media/platform/xilinx/xilinx-tpg.c |    2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/media/platform/xilinx/xilinx-tpg.c
> b/drivers/media/platform/xilinx/xilinx-tpg.c index b5f7d5e..8bd7e37 100644
> --- a/drivers/media/platform/xilinx/xilinx-tpg.c
> +++ b/drivers/media/platform/xilinx/xilinx-tpg.c
> @@ -731,6 +731,7 @@ static int xtpg_parse_of(struct xtpg_device *xtpg)
>  		format = xvip_of_get_format(port);
>  		if (IS_ERR(format)) {
>  			dev_err(dev, "invalid format in DT");
> +			of_node_put(port);
>  			return PTR_ERR(format);
>  		}
> 
> @@ -739,6 +740,7 @@ static int xtpg_parse_of(struct xtpg_device *xtpg)
>  			xtpg->vip_format = format;
>  		} else if (xtpg->vip_format != format) {
>  			dev_err(dev, "in/out format mismatch in DT");
> +			of_node_put(port);
>  			return -EINVAL;
>  		}

-- 
Regards,

Laurent Pinchart


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

* Re: [PATCH 5/8] [media] v4l: xilinx-vipp: add missing of_node_put
  2015-10-25 13:57 ` [PATCH 5/8] [media] v4l: xilinx-vipp: " Julia Lawall
@ 2015-10-26  1:20   ` Laurent Pinchart
  0 siblings, 0 replies; 12+ messages in thread
From: Laurent Pinchart @ 2015-10-26  1:20 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Hyun Kwon, kernel-janitors, Mauro Carvalho Chehab, Michal Simek,
	Sören Brinkmann, linux-media, linux-arm-kernel,
	linux-kernel, Russell King - ARM Linux, Thomas Petazzoni,
	Andrew Lunn, Bjorn Helgaas, Jason Cooper

Hi Julia,

Thank you for the patch.

On Sunday 25 October 2015 14:57:04 Julia Lawall wrote:
> for_each_child_of_node performs an of_node_get on each iteration, so
> a break out of the loop requires an of_node_put.
> 
> A simplified version of the semantic patch that fixes this problem is as
> follows (http://coccinelle.lip6.fr):
> 
> // <smpl>
> @@
> expression root,e;
> local idexpression child;
> @@
> 
>  for_each_child_of_node(root, child) {
>    ... when != of_node_put(child)
>        when != e = child
> (
>    return child;
> 
> +  of_node_put(child);
> ?  return ...;
> )
>    ...
>  }
> // </smpl>
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/media/platform/xilinx/xilinx-vipp.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c
> b/drivers/media/platform/xilinx/xilinx-vipp.c index 7b7cb9c..b9bf24f 100644
> --- a/drivers/media/platform/xilinx/xilinx-vipp.c
> +++ b/drivers/media/platform/xilinx/xilinx-vipp.c
> @@ -476,8 +476,10 @@ static int xvip_graph_dma_init(struct
> xvip_composite_device *xdev)
> 
>  	for_each_child_of_node(ports, port) {
>  		ret = xvip_graph_dma_init_one(xdev, port);
> -		if (ret < 0)
> +		if (ret < 0) {
> +			of_node_put(port);
>  			return ret;
> +		}
>  	}
> 
>  	return 0;

-- 
Regards,

Laurent Pinchart


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

* Re: [PATCH 0/8] add missing of_node_put
  2015-10-25 13:56 [PATCH 0/8] add missing of_node_put Julia Lawall
                   ` (7 preceding siblings ...)
  2015-10-25 13:57 ` [PATCH 8/8] net: mv643xx_eth: " Julia Lawall
@ 2015-10-27  5:08 ` David Miller
  8 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2015-10-27  5:08 UTC (permalink / raw)
  To: Julia.Lawall
  Cc: linux-wireless, kernel-janitors, netdev, linux-arm-kernel,
	linux-kernel, soren.brinkmann, linux-media, linux,
	thomas.petazzoni, andrew, bhelgaas, jason

From: Julia Lawall <Julia.Lawall@lip6.fr>
Date: Sun, 25 Oct 2015 14:56:59 +0100

> The various for_each device_node iterators performs an of_node_get on each
> iteration, so a break out of the loop requires an of_node_put.
> 
> The complete semantic patch that fixes this problem is
> (http://coccinelle.lip6.fr):
 ...

Series applied, thanks a lot Julia.

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

end of thread, other threads:[~2015-10-27  4:52 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-25 13:56 [PATCH 0/8] add missing of_node_put Julia Lawall
2015-10-25 13:57 ` [PATCH 1/8] net: thunderx: " Julia Lawall
2015-10-25 13:57 ` [PATCH 2/8] net: netcp: " Julia Lawall
2015-10-25 13:57 ` [PATCH 3/8] netdev/phy: " Julia Lawall
2015-10-25 13:57 ` [PATCH 4/8] net: phy: mdio: " Julia Lawall
2015-10-25 13:57 ` [PATCH 5/8] [media] v4l: xilinx-vipp: " Julia Lawall
2015-10-26  1:20   ` Laurent Pinchart
2015-10-25 13:57 ` [PATCH 6/8] [media] v4l: xilinx-tpg: " Julia Lawall
2015-10-26  1:19   ` Laurent Pinchart
2015-10-25 13:57 ` [PATCH 7/8] ath6kl: " Julia Lawall
2015-10-25 13:57 ` [PATCH 8/8] net: mv643xx_eth: " Julia Lawall
2015-10-27  5:08 ` [PATCH 0/8] " David Miller

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