diff mbox series

[08/11] thermal/of: add missing of_node_put

Message ID 20230907095521.14053-9-Julia.Lawall@inria.fr (mailing list archive)
State Mainlined, archived
Headers show
Series add missing of_node_put | expand

Commit Message

Julia Lawall Sept. 7, 2023, 9:55 a.m. UTC
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.

This was done using the Coccinelle semantic patch
iterators/for_each_child.cocci

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

---
 drivers/thermal/thermal_of.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Rafael J. Wysocki Sept. 11, 2023, 3:12 p.m. UTC | #1
On Thu, Sep 7, 2023 at 11:56 AM Julia Lawall <Julia.Lawall@inria.fr> 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.
>
> This was done using the Coccinelle semantic patch
> iterators/for_each_child.cocci
>
> Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
>
> ---
>  drivers/thermal/thermal_of.c |    8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff -u -p a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
> --- a/drivers/thermal/thermal_of.c
> +++ b/drivers/thermal/thermal_of.c
> @@ -37,8 +37,10 @@ static int of_find_trip_id(struct device
>          */
>         for_each_child_of_node(trips, t) {
>
> -               if (t == trip)
> +               if (t == trip) {
> +                       of_node_put(t);
>                         goto out;
> +               }
>                 i++;
>         }
>
> @@ -401,8 +403,10 @@ static int thermal_of_for_each_cooling_m
>
>         for_each_child_of_node(cm_np, child) {
>                 ret = thermal_of_for_each_cooling_device(tz_np, child, tz, cdev, action);
> -               if (ret)
> +               if (ret) {
> +                       of_node_put(child);
>                         break;
> +               }
>         }
>
>         of_node_put(cm_np);
>

Applied as 6.6-rc material, thanks!
diff mbox series

Patch

diff -u -p a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
--- a/drivers/thermal/thermal_of.c
+++ b/drivers/thermal/thermal_of.c
@@ -37,8 +37,10 @@  static int of_find_trip_id(struct device
 	 */
 	for_each_child_of_node(trips, t) {
 
-		if (t == trip)
+		if (t == trip) {
+			of_node_put(t);
 			goto out;
+		}
 		i++;
 	}
 
@@ -401,8 +403,10 @@  static int thermal_of_for_each_cooling_m
 
 	for_each_child_of_node(cm_np, child) {
 		ret = thermal_of_for_each_cooling_device(tz_np, child, tz, cdev, action);
-		if (ret)
+		if (ret) {
+			of_node_put(child);
 			break;
+		}
 	}
 
 	of_node_put(cm_np);