Commit dc181759 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
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
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -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);