Revert "thermal: core: call put_device() only after device_register() fails"

This reverts commit a7d736cc3c which is
commit 6c54b7bc8a31ce0f7cc7f8deef05067df414f1d8 upstream.

It is part of a patch series applied to 5.15.91 that breaks the Android
kernel ABI.  If it is really needed, it can be brought back in an
abi-safe way in the future.

Bug: 161946584
Change-Id: I4dce0d2666555d37706bb414cf65e015dfe1c5db
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
Greg Kroah-Hartman
2023-02-02 11:41:41 +00:00
parent ccb2c48531
commit 9617a003cc

View File

@@ -919,20 +919,15 @@ __thermal_cooling_device_register(struct device_node *np,
cdev->devdata = devdata;
ret = cdev->ops->get_max_state(cdev, &cdev->max_state);
if (ret) {
kfree(cdev->type);
goto out_ida_remove;
}
if (ret)
goto out_kfree_type;
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_ida_remove;
goto out_kfree_type;
}
ret = device_register(&cdev->device);
if (ret)
goto out_kfree_type;
@@ -958,8 +953,6 @@ 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_simple_remove(&thermal_cdev_ida, id);