Commit e49a1e1e authored by Dan Carpenter's avatar Dan Carpenter Committed by Rafael J. Wysocki
Browse files

thermal/core: fix error code in __thermal_cooling_device_register()



Return an error pointer if ->get_max_state() fails.  The current code
returns NULL which will cause an oops in the callers.

Fixes: c408b3d1 ("thermal: Validate new state in cur_state_store()")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent a365105c
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -896,7 +896,8 @@ __thermal_cooling_device_register(struct device_node *np,
	cdev->device.class = &thermal_class;
	cdev->device.class = &thermal_class;
	cdev->devdata = devdata;
	cdev->devdata = devdata;


	if (cdev->ops->get_max_state(cdev, &cdev->max_state))
	ret = cdev->ops->get_max_state(cdev, &cdev->max_state);
	if (ret)
		goto out_kfree_type;
		goto out_kfree_type;


	thermal_cooling_device_setup_sysfs(cdev);
	thermal_cooling_device_setup_sysfs(cdev);