Skip to content

Commit d8ac5bb

Browse files
krzkdlezcano
authored andcommitted
thermal/drivers/sprd: Add missing of_node_put for loop iteration
Early exits from for_each_available_child_of_node() should decrement the node reference counter. Reported by Coccinelle: drivers/thermal/sprd_thermal.c:387:1-23: WARNING: Function "for_each_child_of_node" should have of_node_put() before goto around lines 391. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Acked-by: Chunyan Zhang <zhang.lyra@gmail.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20210614192230.19248-2-krzysztof.kozlowski@canonical.com
1 parent 3da9762 commit d8ac5bb

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

drivers/thermal/sprd_thermal.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ static int sprd_thm_probe(struct platform_device *pdev)
388388
sen = devm_kzalloc(&pdev->dev, sizeof(*sen), GFP_KERNEL);
389389
if (!sen) {
390390
ret = -ENOMEM;
391-
goto disable_clk;
391+
goto of_put;
392392
}
393393

394394
sen->data = thm;
@@ -397,13 +397,13 @@ static int sprd_thm_probe(struct platform_device *pdev)
397397
ret = of_property_read_u32(sen_child, "reg", &sen->id);
398398
if (ret) {
399399
dev_err(&pdev->dev, "get sensor reg failed");
400-
goto disable_clk;
400+
goto of_put;
401401
}
402402

403403
ret = sprd_thm_sensor_calibration(sen_child, thm, sen);
404404
if (ret) {
405405
dev_err(&pdev->dev, "efuse cal analysis failed");
406-
goto disable_clk;
406+
goto of_put;
407407
}
408408

409409
sprd_thm_sensor_init(thm, sen);
@@ -416,26 +416,29 @@ static int sprd_thm_probe(struct platform_device *pdev)
416416
dev_err(&pdev->dev, "register thermal zone failed %d\n",
417417
sen->id);
418418
ret = PTR_ERR(sen->tzd);
419-
goto disable_clk;
419+
goto of_put;
420420
}
421421

422422
thm->sensor[sen->id] = sen;
423423
}
424+
/* sen_child set to NULL at this point */
424425

425426
ret = sprd_thm_set_ready(thm);
426427
if (ret)
427-
goto disable_clk;
428+
goto of_put;
428429

429430
ret = sprd_thm_wait_temp_ready(thm);
430431
if (ret)
431-
goto disable_clk;
432+
goto of_put;
432433

433434
for (i = 0; i < thm->nr_sensors; i++)
434435
sprd_thm_toggle_sensor(thm->sensor[i], true);
435436

436437
platform_set_drvdata(pdev, thm);
437438
return 0;
438439

440+
of_put:
441+
of_node_put(sen_child);
439442
disable_clk:
440443
clk_disable_unprepare(thm->clk);
441444
return ret;

0 commit comments

Comments
 (0)