Thermal control fix for 6.2-rc5

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).
 -----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEE4fcc61cGeeHD/fCwgsRv/nhiVHEFAmPK1b8SHHJqd0Byand5
 c29ja2kubmV0AAoJEILEb/54YlRxFWgP/jjzhUZ9UQiRZy0ZXN2Tk+7HKq3XKBVT
 7G+Rj+vX7edKoK8IbYQHaJ4aGFSmDlcweoKpPlfsmW65OIRE5KQGIyWwDG9zOdqx
 iNW08Lls9H8RxZNp6Mn5CLe/pizOoWX6qtGXdQdytAJZgCZ3smDvVcVckO1DCyZH
 BwoIEjlzZltAJEmZiqUciJwtRYrlapflUQnIrMu6b0Sn4Njh2Iz4igTnqIVzQ+4w
 bQnwUBDv+RFS9A+DpUwjKNcxhyE6Y/uLrgreZOtTFiVuxKbKbFot59D6ixr7b/uB
 XlMHIctyCU5lp2BXgAoo+xeAFMru7cOwh+rJLrxW7ZPJFtvIWsfLpAAzZKjflKHn
 sNH92+yWA138phsFi9lBkvs6ebecWf40IQHpUbXV8oxRi2qnfXzn7/N8e9AGo8l7
 2sLMzOa+Kf6nSE0i1KEpVHG9b1NiF7EFfQO2/yQ6Xxw0k8ONRd2aplgu55jY28W6
 E5/+uSEPodoIc76yG/KKtK7UlPGnKaZwYcRf/jd4NR4S+p1yuU9rx56teNrRux96
 ob7HleRtLqRSllfxD5WUjFeUCeEw+DoqTIzAU4+GIcc69OIvMAR4cQEXG9Mif8Ph
 FTz0Wz10DETembye1RXOqmTcFIa0EJxP8KAAkgT6ezV6yOgjt1VzY1SSqaqsG80b
 J8rIJkNn3icy
 =X6Th
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2023-01-20 11:14:41 -08:00
commit dc18175938

View file

@ -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 @@ __thermal_cooling_device_register(struct device_node *np,
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);