Skip to content

Commit dc18175

Browse files
committed
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
2 parents fe563a2 + 6c54b7b commit dc18175

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

drivers/thermal/thermal_core.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -909,15 +909,20 @@ __thermal_cooling_device_register(struct device_node *np,
909909
cdev->devdata = devdata;
910910

911911
ret = cdev->ops->get_max_state(cdev, &cdev->max_state);
912-
if (ret)
913-
goto out_kfree_type;
912+
if (ret) {
913+
kfree(cdev->type);
914+
goto out_ida_remove;
915+
}
914916

915917
thermal_cooling_device_setup_sysfs(cdev);
918+
916919
ret = dev_set_name(&cdev->device, "cooling_device%d", cdev->id);
917920
if (ret) {
921+
kfree(cdev->type);
918922
thermal_cooling_device_destroy_sysfs(cdev);
919-
goto out_kfree_type;
923+
goto out_ida_remove;
920924
}
925+
921926
ret = device_register(&cdev->device);
922927
if (ret)
923928
goto out_kfree_type;
@@ -943,6 +948,8 @@ __thermal_cooling_device_register(struct device_node *np,
943948
thermal_cooling_device_destroy_sysfs(cdev);
944949
kfree(cdev->type);
945950
put_device(&cdev->device);
951+
952+
/* thermal_release() takes care of the rest */
946953
cdev = NULL;
947954
out_ida_remove:
948955
ida_free(&thermal_cdev_ida, id);

0 commit comments

Comments
 (0)