@@ -985,7 +985,7 @@ static void bind_cdev(struct thermal_cooling_device *cdev)
result = device_register(&cdev->device);
if (result) {
ida_simple_remove(&thermal_cdev_ida, cdev->id);
- kfree(cdev);
+ put_device(&cdev->device);
return ERR_PTR(result);
}
@@ -1292,7 +1292,7 @@ struct thermal_zone_device *
dev_set_name(&tz->device, "thermal_zone%d", tz->id);
result = device_register(&tz->device);
if (result)
- goto remove_device_groups;
+ goto release_device;
for (count = 0; count < trips; count++) {
if (tz->ops->get_trip_type(tz, count, &trip_type))
@@ -1347,8 +1347,11 @@ struct thermal_zone_device *
device_unregister(&tz->device);
return ERR_PTR(result);
-remove_device_groups:
- thermal_zone_destroy_device_groups(tz);
+release_device:
+ ida_simple_remove(&thermal_tz_ida, tz->id);
+ put_device(&tz->device);
+ return ERR_PTR(result);
+
remove_id:
ida_simple_remove(&thermal_tz_ida, tz->id);
free_tz: