[PATCH v2 2/2] iio: adc: sun4i-gpadc-iio: Fix error handle when devm_iio_device_register() failed in sun4i_gpadc_probe()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If devm_iio_device_register() failed, the thermal_zone may have been
registered. So we need call thermal_zone_of_sensor_unregister() when
CONFIG_THERMAL_OF is enabled. We fix it by adding a err_register and
gotoing it when devm_iio_device_register() failed.

Fixes: d1caa9905538 ("iio: adc: add support for Allwinner SoCs ADC")
Signed-off-by: Zhang Qilong <zhangqilong3@xxxxxxxxxx>
---
 drivers/iio/adc/sun4i-gpadc-iio.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
index d2535dd28af8..04717571cb2e 100644
--- a/drivers/iio/adc/sun4i-gpadc-iio.c
+++ b/drivers/iio/adc/sun4i-gpadc-iio.c
@@ -656,11 +656,17 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
 	ret = devm_iio_device_register(&pdev->dev, indio_dev);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "could not register the device\n");
-		goto err_map;
+		goto err_register;
 	}
 
 	return 0;
 
+err_register:
+	if (IS_ENABLED(CONFIG_THERMAL_OF)) {
+		devm_thermal_of_zone_unregister(info->sensor_device,
+						info->tzd);
+		info->tzd = NULL;
+	}
 err_map:
 	if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
 		iio_map_array_unregister(indio_dev);
-- 
2.25.1




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux