mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] thermal: drop reference of child node on error
@ 2021-01-20 15:02 Pan Bian
  0 siblings, 0 replies; only message in thread
From: Pan Bian @ 2021-01-20 15:02 UTC (permalink / raw)
  To: Zhang Rui, Daniel Lezcano, Amit Kucheria, Orson Zhai,
	Baolin Wang, Chunyan Zhang
  Cc: linux-pm, linux-kernel, Pan Bian

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

Signed-off-by: Pan Bian <bianpan2016@163.com>
---
 drivers/thermal/sprd_thermal.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/thermal/sprd_thermal.c b/drivers/thermal/sprd_thermal.c
index 3682edb2f466..e843f10167b8 100644
--- a/drivers/thermal/sprd_thermal.c
+++ b/drivers/thermal/sprd_thermal.c
@@ -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;
 		}
-- 
2.17.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-01-20 15:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-20 15:02 [PATCH] thermal: drop reference of child node on error Pan Bian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®