Skip to content

Commit e49a1e1

Browse files
Dan Carpenterrafaeljw
authored andcommitted
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: c408b3d ("thermal: Validate new state in cur_state_store()") Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent a365105 commit e49a1e1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/thermal/thermal_core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,8 @@ __thermal_cooling_device_register(struct device_node *np,
896896
cdev->device.class = &thermal_class;
897897
cdev->devdata = devdata;
898898

899-
if (cdev->ops->get_max_state(cdev, &cdev->max_state))
899+
ret = cdev->ops->get_max_state(cdev, &cdev->max_state);
900+
if (ret)
900901
goto out_kfree_type;
901902

902903
thermal_cooling_device_setup_sysfs(cdev);

0 commit comments

Comments
 (0)