Skip to content

Commit 09700c5

Browse files
Yuuoniydlezcano
authored andcommitted
thermal/drivers/imx_sc_thermal: Fix refcount leak in imx_sc_thermal_probe
of_find_node_by_name() returns a node pointer with refcount incremented, we should use of_node_put() on it when done. Add missing of_node_put() to avoid refcount leak. Fixes: e20db70 ("thermal: imx_sc: add i.MX system controller thermal support") Signed-off-by: Miaoqian Lin <linmq006@gmail.com> Link: https://lore.kernel.org/r/20220517055121.18092-1-linmq006@gmail.com Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
1 parent 98a160e commit 09700c5

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

drivers/thermal/imx_sc_thermal.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ static int imx_sc_thermal_probe(struct platform_device *pdev)
9494
sensor = devm_kzalloc(&pdev->dev, sizeof(*sensor), GFP_KERNEL);
9595
if (!sensor) {
9696
of_node_put(child);
97-
of_node_put(sensor_np);
98-
return -ENOMEM;
97+
ret = -ENOMEM;
98+
goto put_node;
9999
}
100100

101101
ret = thermal_zone_of_get_sensor_id(child,
@@ -124,7 +124,9 @@ static int imx_sc_thermal_probe(struct platform_device *pdev)
124124
dev_warn(&pdev->dev, "failed to add hwmon sysfs attributes\n");
125125
}
126126

127+
put_node:
127128
of_node_put(sensor_np);
129+
of_node_put(np);
128130

129131
return ret;
130132
}

0 commit comments

Comments
 (0)