Skip to contentSkip to conversation

thermal: db8500: Fix checking return value of thermal_zone_device_register

PATCH Applied Axel Lin 3 participants 6 messages Mar 12, 2013 – Mar 25, 2013 Thermal

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/2 thermal: db8500: Fix checking return value of thermal_zone_device_register

thermal_zone_device_register() returns ERR_PTR on error, thus use IS_ERR rather than IS_ERR_OR_NULL to check return value.

---
 drivers/thermal/db8500_thermal.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/db8500_thermal.c +1 -1
index 61ce60a..6bdcec4 100644
@@ -447,7 +447,7 @@ static int db8500_thermal_probe(struct platform_device *pdev)
 	pzone->therm_dev = thermal_zone_device_register("db8500_thermal_zone",
 		ptrips->num_trips, 0, pzone, &thdev_ops, NULL, 0, 0);
 
-	if (IS_ERR_OR_NULL(pzone->therm_dev)) {
+	if (IS_ERR(pzone->therm_dev)) {
 		dev_err(&pdev->dev, "Register thermal zone device failed.\n");
 		return PTR_ERR(pzone->therm_dev);
 	}
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH 2/2 thermal: db8500: Fix missing mutex_unlock() in probe error paths

---
 drivers/thermal/db8500_thermal.c |   17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/thermal/db8500_thermal.c +11 -6
index 6bdcec4..1e3b3bf 100644
@@ -419,7 +419,8 @@ static int db8500_thermal_probe(struct platform_device *pdev)
 	low_irq = platform_get_irq_byname(pdev, "IRQ_HOTMON_LOW");
 	if (low_irq < 0) {
 		dev_err(&pdev->dev, "Get IRQ_HOTMON_LOW failed.\n");
-		return low_irq;
+		ret = low_irq;
+		goto out_unlock;
 	}
 
 	ret = devm_request_threaded_irq(&pdev->dev, low_irq, NULL,
@@ -427,13 +428,14 @@ static int db8500_thermal_probe(struct platform_device *pdev)
 		"dbx500_temp_low", pzone);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "Failed to allocate temp low irq.\n");
-		return ret;
+		goto out_unlock;
 	}
 
 	high_irq = platform_get_irq_byname(pdev, "IRQ_HOTMON_HIGH");
 	if (high_irq < 0) {
 		dev_err(&pdev->dev, "Get IRQ_HOTMON_HIGH failed.\n");
-		return high_irq;
+		ret = high_irq;
+		goto out_unlock;
 	}
 
 	ret = devm_request_threaded_irq(&pdev->dev, high_irq, NULL,
@@ -441,7 +443,7 @@ static int db8500_thermal_probe(struct platform_device *pdev)
 		"dbx500_temp_high", pzone);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "Failed to allocate temp high irq.\n");
-		return ret;
+		goto out_unlock;
 	}
 
 	pzone->therm_dev = thermal_zone_device_register("db8500_thermal_zone",
@@ -449,7 +451,8 @@ static int db8500_thermal_probe(struct platform_device *pdev)
 
 	if (IS_ERR(pzone->therm_dev)) {
 		dev_err(&pdev->dev, "Register thermal zone device failed.\n");
-		return PTR_ERR(pzone->therm_dev);
+		ret = PTR_ERR(pzone->therm_dev);
+		goto out_unlock;
 	}
 	dev_info(&pdev->dev, "Thermal zone device registered.\n");
 
@@ -461,9 +464,11 @@ static int db8500_thermal_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, pzone);
 	pzone->mode = THERMAL_DEVICE_ENABLED;
+
+out_unlock:
 	mutex_unlock(&pzone->th_lock);
 
-	return 0;
+	return ret;
 }
 
 static int db8500_thermal_remove(struct platform_device *pdev)
Signature · 1 line
1.7.9.5
#2 lore raw

Re: [PATCH 2/2] thermal: db8500: Fix missing mutex_unlock() in probe error paths

On 12 March 2013 23:43, Axel Lin <[email protected]> wrote:

It is better to say some commit message here I think.

Quoted 56 lines
---
 drivers/thermal/db8500_thermal.c |   17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/thermal/db8500_thermal.c +8 -5
index 6bdcec4..1e3b3bf 100644
@@ -419,7 +419,8 @@ static int db8500_thermal_probe(struct platform_device *pdev)
        low_irq = platform_get_irq_byname(pdev, "IRQ_HOTMON_LOW");
        if (low_irq < 0) {
                dev_err(&pdev->dev, "Get IRQ_HOTMON_LOW failed.\n");
-               return low_irq;
+               ret = low_irq;
+               goto out_unlock;
        }
 
        ret = devm_request_threaded_irq(&pdev->dev, low_irq, NULL,
@@ -427,13 +428,14 @@ static int db8500_thermal_probe(struct platform_device *pdev)
                "dbx500_temp_low", pzone);
        if (ret < 0) {
                dev_err(&pdev->dev, "Failed to allocate temp low irq.\n");
-               return ret;
+               goto out_unlock;
        }
 
        high_irq = platform_get_irq_byname(pdev, "IRQ_HOTMON_HIGH");
        if (high_irq < 0) {
                dev_err(&pdev->dev, "Get IRQ_HOTMON_HIGH failed.\n");
-               return high_irq;
+               ret = high_irq;
+               goto out_unlock;
        }
 
        ret = devm_request_threaded_irq(&pdev->dev, high_irq, NULL,
@@ -441,7 +443,7 @@ static int db8500_thermal_probe(struct platform_device *pdev)
                "dbx500_temp_high", pzone);
        if (ret < 0) {
                dev_err(&pdev->dev, "Failed to allocate temp high irq.\n");
-               return ret;
+               goto out_unlock;
        }
 
        pzone->therm_dev = thermal_zone_device_register("db8500_thermal_zone",
@@ -449,7 +451,8 @@ static int db8500_thermal_probe(struct platform_device *pdev)
 
        if (IS_ERR(pzone->therm_dev)) {
                dev_err(&pdev->dev, "Register thermal zone device failed.\n");
-               return PTR_ERR(pzone->therm_dev);
+               ret = PTR_ERR(pzone->therm_dev);
+               goto out_unlock;
        }
        dev_info(&pdev->dev, "Thermal zone device registered.\n");
 

drivers/thermal/db8500_thermal.c static int db8500_thermal_probe(struct platform_device *pdev) · line 468

Quoted 5 lines
drivers/thermal/db8500_thermal.c +2 -0
@@ -461,9 +464,11 @@ static int db8500_thermal_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, pzone);
        pzone->mode = THERMAL_DEVICE_ENABLED;
+
+out_unlock:

This was my carelessness really, thanks.

Quoted 16 lines
drivers/thermal/db8500_thermal.c +1 -2
        mutex_unlock(&pzone->th_lock);
 
-       return 0;
+       return ret;
 }
 
 static int db8500_thermal_remove(struct platform_device *pdev)
--

1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#3 lore raw

Re: [PATCH 2/2] thermal: db8500: Fix missing mutex_unlock() in probe error paths

2013/3/13 Hongbo Zhang <[email protected]>:

Quoted 3 lines · Axel Lin

It is better to say some commit message here I think.

In this case, the subject line is *very clear* about the change. I think it is ok to avoid duplicate the same commit message.

Regards,
Axel

reviewer Applied
#4 lore raw

Re: [PATCH 2/2] thermal: db8500: Fix missing mutex_unlock() in probe error paths

In reply to Axel Lin
Quoted 1 line · Axel Lin

applied to thermal -next.

thanks,
rui

Quoted 67 lines
---
 drivers/thermal/db8500_thermal.c |   17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/thermal/db8500_thermal.c +11 -6
index 6bdcec4..1e3b3bf 100644
@@ -419,7 +419,8 @@ static int db8500_thermal_probe(struct platform_device *pdev)
 	low_irq = platform_get_irq_byname(pdev, "IRQ_HOTMON_LOW");
 	if (low_irq < 0) {
 		dev_err(&pdev->dev, "Get IRQ_HOTMON_LOW failed.\n");
-		return low_irq;
+		ret = low_irq;
+		goto out_unlock;
 	}
 
 	ret = devm_request_threaded_irq(&pdev->dev, low_irq, NULL,
@@ -427,13 +428,14 @@ static int db8500_thermal_probe(struct platform_device *pdev)
 		"dbx500_temp_low", pzone);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "Failed to allocate temp low irq.\n");
-		return ret;
+		goto out_unlock;
 	}
 
 	high_irq = platform_get_irq_byname(pdev, "IRQ_HOTMON_HIGH");
 	if (high_irq < 0) {
 		dev_err(&pdev->dev, "Get IRQ_HOTMON_HIGH failed.\n");
-		return high_irq;
+		ret = high_irq;
+		goto out_unlock;
 	}
 
 	ret = devm_request_threaded_irq(&pdev->dev, high_irq, NULL,
@@ -441,7 +443,7 @@ static int db8500_thermal_probe(struct platform_device *pdev)
 		"dbx500_temp_high", pzone);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "Failed to allocate temp high irq.\n");
-		return ret;
+		goto out_unlock;
 	}
 
 	pzone->therm_dev = thermal_zone_device_register("db8500_thermal_zone",
@@ -449,7 +451,8 @@ static int db8500_thermal_probe(struct platform_device *pdev)
 
 	if (IS_ERR(pzone->therm_dev)) {
 		dev_err(&pdev->dev, "Register thermal zone device failed.\n");
-		return PTR_ERR(pzone->therm_dev);
+		ret = PTR_ERR(pzone->therm_dev);
+		goto out_unlock;
 	}
 	dev_info(&pdev->dev, "Thermal zone device registered.\n");
 
@@ -461,9 +464,11 @@ static int db8500_thermal_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, pzone);
 	pzone->mode = THERMAL_DEVICE_ENABLED;
+
+out_unlock:
 	mutex_unlock(&pzone->th_lock);
 
-	return 0;
+	return ret;
 }
 
 static int db8500_thermal_remove(struct platform_device *pdev)
reviewer Applied
#5 lore raw
In reply to Axel Lin
Quoted 4 lines · Axel Lin

thermal_zone_device_register() returns ERR_PTR on error, thus use IS_ERR rather than IS_ERR_OR_NULL to check return value.

applied to thermal -next.

thanks,
rui

Quoted 17 lines
---
 drivers/thermal/db8500_thermal.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/db8500_thermal.c +1 -1
index 61ce60a..6bdcec4 100644
@@ -447,7 +447,7 @@ static int db8500_thermal_probe(struct platform_device *pdev)
 	pzone->therm_dev = thermal_zone_device_register("db8500_thermal_zone",
 		ptrips->num_trips, 0, pzone, &thdev_ops, NULL, 0, 0);
 
-	if (IS_ERR_OR_NULL(pzone->therm_dev)) {
+	if (IS_ERR(pzone->therm_dev)) {
 		dev_err(&pdev->dev, "Register thermal zone device failed.\n");
 		return PTR_ERR(pzone->therm_dev);
 	}