Skip to contentSkip to conversation

thermal: drop reference of child node on error

PATCH New Pan Bian 1 participant 1 message Jan 20, 2021

Subsystems (2)
lore
Share & tools
lore

Pan Bian

author
#0 lore raw

PATCH 1/1 thermal: drop reference of child node on error

Drop the reference of the child node sen_child before goto out of the loop.

---
 drivers/thermal/sprd_thermal.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/thermal/sprd_thermal.c +4 -0
index 3682edb2f466..e843f10167b8 100644
@@ -387,6 +387,7 @@ static int sprd_thm_probe(struct platform_device *pdev)
 	for_each_child_of_node(np, sen_child) {
 		sen = devm_kzalloc(&pdev->dev, sizeof(*sen), GFP_KERNEL);
 		if (!sen) {
+			of_node_put(sen_child);
 			ret = -ENOMEM;
 			goto disable_clk;
 		}
@@ -397,12 +398,14 @@ static int sprd_thm_probe(struct platform_device *pdev)
 		ret = of_property_read_u32(sen_child, "reg", &sen->id);
 		if (ret) {
 			dev_err(&pdev->dev, "get sensor reg failed");
+			of_node_put(sen_child);
 			goto disable_clk;
 		}
 
 		ret = sprd_thm_sensor_calibration(sen_child, thm, sen);
 		if (ret) {
 			dev_err(&pdev->dev, "efuse cal analysis failed");
+			of_node_put(sen_child);
 			goto disable_clk;
 		}
 
@@ -415,6 +418,7 @@ static int sprd_thm_probe(struct platform_device *pdev)
 		if (IS_ERR(sen->tzd)) {
 			dev_err(&pdev->dev, "register thermal zone failed %d\n",
 				sen->id);
+			of_node_put(sen_child);
 			ret = PTR_ERR(sen->tzd);
 			goto disable_clk;
 		}
Signature · 1 line
2.17.1