ACPI: thermal: Check whether cooling device exists before unregistering
authorZhao Yakui <yakui.zhao@intel.com>
Fri, 15 Feb 2008 00:34:37 +0000 (08:34 +0800)
committerLen Brown <len.brown@intel.com>
Fri, 15 Feb 2008 23:23:50 +0000 (18:23 -0500)
OS should check whether the cooling device exists before it is unregistered.
If it doesn't exists, it is unnecessary to remove the sysfs link
and call the function of thermal_cooling_device_unregister.

http://bugzilla.kernel.org/show_bug.cgi?id=9982

Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Tested-by    : Dhaval Giani <dhaval@linux.vnet.ibm.com>
Signed-off-by: Len Brown <len.brown@intel.com>
drivers/acpi/processor_core.c

index 75ccf5d18bf4e3630e892dd0021a8c890a0fc0c2..697335c8423e3865e93ae906834c97386d358d24 100644 (file)
@@ -809,10 +809,12 @@ static int acpi_processor_remove(struct acpi_device *device, int type)
 
        acpi_processor_remove_fs(device);
 
-       sysfs_remove_link(&device->dev.kobj, "thermal_cooling");
-       sysfs_remove_link(&pr->cdev->device.kobj, "device");
-       thermal_cooling_device_unregister(pr->cdev);
-       pr->cdev = NULL;
+       if (pr->cdev) {
+               sysfs_remove_link(&device->dev.kobj, "thermal_cooling");
+               sysfs_remove_link(&pr->cdev->device.kobj, "device");
+               thermal_cooling_device_unregister(pr->cdev);
+               pr->cdev = NULL;
+       }
 
        processors[pr->id] = NULL;