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
[ Upstream commit e49a1e1 ]

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>
Stable-dep-of: 6c54b7b ("thermal: core: call put_device() only after device_register() fails")
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Dan Carpenter authored and gregkh committed Feb 1, 2023
1 parent 80bb3b9 commit d4dbbbb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/thermal/thermal_core.c
Expand Up @@ -892,7 +892,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);
Expand Down

0 comments on commit d4dbbbb

Please sign in to comment.