Skip to contentSkip to conversation

hwmon: Fix freeing of gpio_data and irq

PATCH In review Roel Kluin 2 participants 2 messages Aug 22, 2009 – Aug 23, 2009 Hardware monitoring

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 hwmon: Fix freeing of gpio_data and irq

If already requested, gpio_data and irq should be freed in the case of an error.

---
please review, especially the added free_irq(): are its arguments ok like this?

drivers/hwmon/sht15.c +4 -2
index 6290a25..303c026 100644
@@ -562,7 +562,7 @@ static int __devinit sht15_probe(struct platform_device *pdev)
 	ret = sysfs_create_group(&pdev->dev.kobj, &sht15_attr_group);
 	if (ret) {
 		dev_err(&pdev->dev, "sysfs create failed");
-		goto err_free_data;
+		goto err_release_gpio_data;
 	}
 
 	ret = request_irq(gpio_to_irq(data->pdata->gpio_data),
@@ -581,10 +581,12 @@ static int __devinit sht15_probe(struct platform_device *pdev)
 	data->hwmon_dev = hwmon_device_register(data->dev);
 	if (IS_ERR(data->hwmon_dev)) {
 		ret = PTR_ERR(data->hwmon_dev);
-		goto err_release_gpio_data;
+		goto err_release_irq;
 	}
 	return 0;
 
+err_release_irq:
+	free_irq(gpio_to_irq(data->pdata->gpio_data), data);
 err_release_gpio_data:
 	gpio_free(data->pdata->gpio_data);
 err_release_gpio_sck:

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

Acked-by on v1 1/1
#1 lore raw

Hi Roel,

Quoted 2 lines

If already requested, gpio_data and irq should be freed in the case of an error.

All looks good to me. Good spot in both cases, thanks.

Andrew, can you push these through as fixes? You'd be pretty unlucky to hit either of them, but better safe than sorry.

Thanks

Quoted 5 lines

---
please review, especially the added free_irq(): are its arguments ok like this?

Yup, same as in the remove function and given irq is disabled anyway at that point all should be fine.

Quoted 18 lines
drivers/hwmon/sht15.c +1 -1
index 6290a25..303c026 100644
@@ -562,7 +562,7 @@ static int __devinit sht15_probe(struct platform_device *pdev)
 	ret = sysfs_create_group(&pdev->dev.kobj, &sht15_attr_group);
 	if (ret) {
 		dev_err(&pdev->dev, "sysfs create failed");
-		goto err_free_data;
+		goto err_release_gpio_data;
 	}
 
 	ret = request_irq(gpio_to_irq(data->pdata->gpio_data),
@@ -581,10 +581,12 @@ static int __devinit sht15_probe(struct platform_device *pdev)
 	data->hwmon_dev = hwmon_device_register(data->dev);
 	if (IS_ERR(data->hwmon_dev)) {
 		ret = PTR_ERR(data->hwmon_dev);

drivers/hwmon/sht15.c static int __devinit sht15_probe(struct platform_device *pdev) · line 592

Quoted 10 lines
drivers/hwmon/sht15.c +3 -1
-		goto err_release_gpio_data;
+		goto err_release_irq;
 	}
 	return 0;
 
+err_release_irq:
+	free_irq(gpio_to_irq(data->pdata->gpio_data), data);
 err_release_gpio_data:
 	gpio_free(data->pdata->gpio_data);
 err_release_gpio_sck:

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors