projects/linux·commit dc181759

Merge tag 'thermal-6.2-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

dc181759 · Linus Torvalds <[email protected]> · 2023-01-20 11:14:41 -08:00

Pull thermal control fix from Rafael Wysocki:
 "Modify __thermal_cooling_device_register() to make it call
  put_device() after invoking device_register() and fix up a few error
  paths calling thermal_cooling_device_destroy_sysfs() unnecessarily
  (Viresh Kumar)"

* tag 'thermal-6.2-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  thermal: core: call put_device() only after device_register() fails
Commit
dc18175938e65e979b866f23dc5b93e81d649cc4
Parents
fe563a2c · 6c54b7bc

Merge commit. Changes below are compared with the first parent: fe563a2c.

Changes

1 files changed · +10 −3

FileStatusAddDelContent
drivers/thermal/thermal_core.cmodified+10−3View file

drivers/thermal/thermal_core.c

View file
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index f17ab23..77bd47d 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -909,15 +909,20 @@ __thermal_cooling_device_register(struct device_node *np,
cdev->devdata = devdata;
ret = cdev->ops->get_max_state(cdev, &cdev->max_state);
- if (ret)
- goto out_kfree_type;
+ if (ret) {
+ kfree(cdev->type);
+ goto out_ida_remove;
+ }
thermal_cooling_device_setup_sysfs(cdev);
+
ret = dev_set_name(&cdev->device, "cooling_device%d", cdev->id);
if (ret) {
+ kfree(cdev->type);
thermal_cooling_device_destroy_sysfs(cdev);
- goto out_kfree_type;
+ goto out_ida_remove;
}
+
ret = device_register(&cdev->device);
if (ret)
goto out_kfree_type;
@@ -943,6 +948,8 @@ out_kfree_type:
thermal_cooling_device_destroy_sysfs(cdev);
kfree(cdev->type);
put_device(&cdev->device);
+
+ /* thermal_release() takes care of the rest */
cdev = NULL;
out_ida_remove:
ida_free(&thermal_cdev_ida, id);