Skip to content

Commit

Permalink
thermal/core: fix error code in __thermal_cooling_device_register()
Browse files Browse the repository at this point in the history
Return an error pointer if ->get_max_state() fails.  The current code
returns NULL which will cause an oops in the callers.

Fixes: c408b3d ("thermal: Validate new state in cur_state_store()")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Dan Carpenter authored and Rafael J. Wysocki committed Oct 28, 2022
1 parent a365105 commit e49a1e1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/thermal/thermal_core.c
Original file line number Diff line number Diff line change
@@ -896,7 +896,8 @@ __thermal_cooling_device_register(struct device_node *np,
cdev->device.class = &thermal_class;
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;

thermal_cooling_device_setup_sysfs(cdev);

0 comments on commit e49a1e1

Please sign in to comment.