mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
thermal/of: Fix potential uninitialized value access
[ Upstream commitf96801f0cf] If of_parse_phandle_with_args() called from __thermal_of_bind() or __thermal_of_unbind() fails, cooling_spec.np will not be initialized, so move the of_node_put() calls below the respective return value checks to avoid dereferencing an uninitialized pointer. Fixes:3fd6d6e2b4("thermal/of: Rework the thermal device tree initialization") Signed-off-by: Peng Fan <peng.fan@nxp.com> [ rjw: Subject and changelog edits ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
61e61e0e0a
commit
c9091e0310
@@ -292,13 +292,13 @@ static int __thermal_of_unbind(struct device_node *map_np, int index, int trip_i
|
|||||||
ret = of_parse_phandle_with_args(map_np, "cooling-device", "#cooling-cells",
|
ret = of_parse_phandle_with_args(map_np, "cooling-device", "#cooling-cells",
|
||||||
index, &cooling_spec);
|
index, &cooling_spec);
|
||||||
|
|
||||||
of_node_put(cooling_spec.np);
|
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
pr_err("Invalid cooling-device entry\n");
|
pr_err("Invalid cooling-device entry\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
of_node_put(cooling_spec.np);
|
||||||
|
|
||||||
if (cooling_spec.args_count < 2) {
|
if (cooling_spec.args_count < 2) {
|
||||||
pr_err("wrong reference to cooling device, missing limits\n");
|
pr_err("wrong reference to cooling device, missing limits\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@@ -325,13 +325,13 @@ static int __thermal_of_bind(struct device_node *map_np, int index, int trip_id,
|
|||||||
ret = of_parse_phandle_with_args(map_np, "cooling-device", "#cooling-cells",
|
ret = of_parse_phandle_with_args(map_np, "cooling-device", "#cooling-cells",
|
||||||
index, &cooling_spec);
|
index, &cooling_spec);
|
||||||
|
|
||||||
of_node_put(cooling_spec.np);
|
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
pr_err("Invalid cooling-device entry\n");
|
pr_err("Invalid cooling-device entry\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
of_node_put(cooling_spec.np);
|
||||||
|
|
||||||
if (cooling_spec.args_count < 2) {
|
if (cooling_spec.args_count < 2) {
|
||||||
pr_err("wrong reference to cooling device, missing limits\n");
|
pr_err("wrong reference to cooling device, missing limits\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|||||||
Reference in New Issue
Block a user