]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
thermal: of: fix OF node leak in of_thermal_zone_find()
authorJoe Hattori <joe@pf.is.s.u-tokyo.ac.jp>
Tue, 24 Dec 2024 03:18:09 +0000 (12:18 +0900)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 7 Jan 2025 19:05:32 +0000 (20:05 +0100)
of_thermal_zone_find() calls of_parse_phandle_with_args(), but does not
release the OF node reference obtained by it.

Add a of_node_put() call when the call is successful.

Fixes: 3fd6d6e2b4e8 ("thermal/of: Rework the thermal device tree initialization")
Signed-off-by: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp>
Link: https://patch.msgid.link/20241224031809.950461-1-joe@pf.is.s.u-tokyo.ac.jp
[ rjw: Changelog edit ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/thermal/thermal_of.c

index fab11b98ca4952d23d0232998433bd0650b53d24..5ab4ce4daaebdf0210d9b318ae17b3eb8a4bccaf 100644 (file)
@@ -160,6 +160,7 @@ static struct device_node *of_thermal_zone_find(struct device_node *sensor, int
                                return ERR_PTR(ret);
                        }
 
+                       of_node_put(sensor_specs.np);
                        if ((sensor == sensor_specs.np) && id == (sensor_specs.args_count ?
                                                                  sensor_specs.args[0] : 0)) {
                                pr_debug("sensor %pOFn id=%d belongs to %pOFn\n", sensor, id, child);