thermal: mtk_thermal: Check return value of devm_thermal_zone_of_sensor_register
authorAxel Lin <axel.lin@ingics.com>
Wed, 7 Sep 2016 09:24:52 +0000 (17:24 +0800)
committerZhang Rui <rui.zhang@intel.com>
Tue, 27 Sep 2016 06:02:16 +0000 (14:02 +0800)
devm_thermal_zone_of_sensor_register can fail, so check it's return value.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
drivers/thermal/mtk_thermal.c

index 7b233c718e2e06d59a3c4c0244eb344c18769267..34169c32d4956ffe8bb146ab0ae66a8f4ebbdbf2 100644 (file)
@@ -584,6 +584,7 @@ static int mtk_thermal_probe(struct platform_device *pdev)
        struct resource *res;
        const struct of_device_id *of_id;
        u64 auxadc_phys_base, apmixed_phys_base;
+       struct thermal_zone_device *tzdev;
 
        mt = devm_kzalloc(&pdev->dev, sizeof(*mt), GFP_KERNEL);
        if (!mt)
@@ -666,11 +667,17 @@ static int mtk_thermal_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, mt);
 
-       devm_thermal_zone_of_sensor_register(&pdev->dev, 0, mt,
-                                            &mtk_thermal_ops);
+       tzdev = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, mt,
+                                                    &mtk_thermal_ops);
+       if (IS_ERR(tzdev)) {
+               ret = PTR_ERR(tzdev);
+               goto err_disable_clk_peri_therm;
+       }
 
        return 0;
 
+err_disable_clk_peri_therm:
+       clk_disable_unprepare(mt->clk_peri_therm);
 err_disable_clk_auxadc:
        clk_disable_unprepare(mt->clk_auxadc);