Commit dc181759 authored by Linus Torvalds's avatar Linus Torvalds

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

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
parents fe563a2c 6c54b7bc
...@@ -909,15 +909,20 @@ __thermal_cooling_device_register(struct device_node *np, ...@@ -909,15 +909,20 @@ __thermal_cooling_device_register(struct device_node *np,
cdev->devdata = devdata; cdev->devdata = devdata;
ret = cdev->ops->get_max_state(cdev, &cdev->max_state); ret = cdev->ops->get_max_state(cdev, &cdev->max_state);
if (ret) if (ret) {
goto out_kfree_type; kfree(cdev->type);
goto out_ida_remove;
}
thermal_cooling_device_setup_sysfs(cdev); thermal_cooling_device_setup_sysfs(cdev);
ret = dev_set_name(&cdev->device, "cooling_device%d", cdev->id); ret = dev_set_name(&cdev->device, "cooling_device%d", cdev->id);
if (ret) { if (ret) {
kfree(cdev->type);
thermal_cooling_device_destroy_sysfs(cdev); thermal_cooling_device_destroy_sysfs(cdev);
goto out_kfree_type; goto out_ida_remove;
} }
ret = device_register(&cdev->device); ret = device_register(&cdev->device);
if (ret) if (ret)
goto out_kfree_type; goto out_kfree_type;
...@@ -943,6 +948,8 @@ __thermal_cooling_device_register(struct device_node *np, ...@@ -943,6 +948,8 @@ __thermal_cooling_device_register(struct device_node *np,
thermal_cooling_device_destroy_sysfs(cdev); thermal_cooling_device_destroy_sysfs(cdev);
kfree(cdev->type); kfree(cdev->type);
put_device(&cdev->device); put_device(&cdev->device);
/* thermal_release() takes care of the rest */
cdev = NULL; cdev = NULL;
out_ida_remove: out_ida_remove:
ida_free(&thermal_cdev_ida, id); ida_free(&thermal_cdev_ida, id);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment