linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/9] add missing of_node_put
@ 2015-10-24 14:42 Julia Lawall
  2015-10-24 14:42 ` [PATCH 6/9] Bluetooth: btmrvl: " Julia Lawall
  2015-10-26  8:48 ` [PATCH 0/9] " Jacek Anaszewski
  0 siblings, 2 replies; 4+ messages in thread
From: Julia Lawall @ 2015-10-24 14:42 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: kernel-janitors, linux-bluetooth, linux-leds, linux-kernel,
	dri-devel, linux-tegra, linux-gpio, 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/bluetooth/btmrvl_main.c  |    5 ++++-
 drivers/gpu/drm/tegra/dc.c       |    4 +++-
 drivers/gpu/host1x/bus.c         |    4 +++-
 drivers/leds/leds-88pm860x.c     |    1 +
 drivers/leds/leds-bcm6328.c      |    4 +++-
 drivers/leds/leds-bcm6358.c      |    4 +++-
 drivers/leds/leds-powernv.c      |    8 ++++++--
 drivers/pinctrl/pinctrl-at91.c   |    5 ++++-
 drivers/soc/ti/knav_qmss_queue.c |    3 +++
 9 files changed, 30 insertions(+), 8 deletions(-)

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

* [PATCH 6/9] Bluetooth: btmrvl: add missing of_node_put
  2015-10-24 14:42 [PATCH 0/9] add missing of_node_put Julia Lawall
@ 2015-10-24 14:42 ` Julia Lawall
  2015-10-25 19:54   ` Marcel Holtmann
  2015-10-26  8:48 ` [PATCH 0/9] " Jacek Anaszewski
  1 sibling, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2015-10-24 14:42 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: kernel-janitors, Gustavo Padovan, Johan Hedberg, linux-bluetooth,
	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/bluetooth/btmrvl_main.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/bluetooth/btmrvl_main.c b/drivers/bluetooth/btmrvl_main.c
index 6ba2286..6af9173 100644
--- a/drivers/bluetooth/btmrvl_main.c
+++ b/drivers/bluetooth/btmrvl_main.c
@@ -516,14 +516,17 @@ static int btmrvl_check_device_tree(struct btmrvl_private *priv)
 		ret = of_property_read_u8_array(dt_node, "btmrvl,cal-data",
 						cal_data + BT_CAL_HDR_LEN,
 						BT_CAL_DATA_SIZE);
-		if (ret)
+		if (ret) {
+			of_node_put(dt_node);
 			return ret;
+		}
 
 		BT_DBG("Use cal data from device tree");
 		ret = btmrvl_download_cal_data(priv, cal_data,
 					       BT_CAL_DATA_SIZE);
 		if (ret) {
 			BT_ERR("Fail to download calibrate data");
+			of_node_put(dt_node);
 			return ret;
 		}
 	}

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

* Re: [PATCH 6/9] Bluetooth: btmrvl: add missing of_node_put
  2015-10-24 14:42 ` [PATCH 6/9] Bluetooth: btmrvl: " Julia Lawall
@ 2015-10-25 19:54   ` Marcel Holtmann
  0 siblings, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2015-10-25 19:54 UTC (permalink / raw)
  To: Julia Lawall
  Cc: kernel-janitors, Gustavo F. Padovan, Johan Hedberg,
	linux-bluetooth, linux-kernel, Russell King - ARM Linux,
	Thomas Petazzoni, Andrew Lunn, Bjorn Helgaas, Jason Cooper

Hi Julia,

> 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/bluetooth/btmrvl_main.c |    5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel


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

* Re: [PATCH 0/9] add missing of_node_put
  2015-10-24 14:42 [PATCH 0/9] add missing of_node_put Julia Lawall
  2015-10-24 14:42 ` [PATCH 6/9] Bluetooth: btmrvl: " Julia Lawall
@ 2015-10-26  8:48 ` Jacek Anaszewski
  1 sibling, 0 replies; 4+ messages in thread
From: Jacek Anaszewski @ 2015-10-26  8:48 UTC (permalink / raw)
  To: Julia Lawall
  Cc: linux-arm-kernel, kernel-janitors, linux-bluetooth, linux-leds,
	linux-kernel, dri-devel, linux-tegra, linux-gpio,
	Russell King - ARM Linux, Thomas Petazzoni, Andrew Lunn,
	Bjorn Helgaas, Jason Cooper

Hi Julia,

Patches 1-4 have been applied to the LED tree, thanks.

On 10/24/2015 04:42 PM, Julia Lawall wrote:
> 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):
>
[...]

-- 
Best Regards,
Jacek Anaszewski

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

end of thread, other threads:[~2015-10-26  8:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-24 14:42 [PATCH 0/9] add missing of_node_put Julia Lawall
2015-10-24 14:42 ` [PATCH 6/9] Bluetooth: btmrvl: " Julia Lawall
2015-10-25 19:54   ` Marcel Holtmann
2015-10-26  8:48 ` [PATCH 0/9] " Jacek Anaszewski

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