[PATCH 3/4] provide error handling for unclean objects

Glauber Costa
2008-02-18T21:05:18Z

Previously, if acpi_processor_start() failed to
create sysfs nodes, it would leave stuff to be cleaned,
that won't perish in acpi_processor_remove(),
since we'll have pr->cdev == NULL.

This patch cleans those objects.

Signed-off-by: Glauber Costa <gcosta@redhat.com>
---
drivers/acpi/processor_core.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 5023410..06a230a 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -680,11 +680,12 @@ #endif
result = sysfs_create_link(&device->dev.kobj, &cdev->device.kobj,
"thermal_cooling");
if (result)
- return result;
+ goto err_thermal;
+
result = sysfs_create_link(&cdev->device.kobj, &device->dev.kobj,
"device");
if (result)
- return result;
+ goto err_sysfs;

pr->cdev = cdev;

@@ -694,9 +695,13 @@ #endif
printk(" %d throttling states", pr->throttling.state_count);
printk(")\n");
}
+ return result;

- end:
-
+err_sysfs:
+ sysfs_remove_link(&device->dev.kobj, "thermal_cooling");
+err_thermal:
+ thermal_cooling_device_unregister(pr->cdev);
+end:
return result;
}

--
1.4.2