summaryrefslogtreecommitdiffstats
path: root/drivers/thermal
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2022-10-28 18:02:34 +0300
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2022-10-28 19:59:51 +0200
commite49a1e1ee078aee21006192076a8d93335e0daa9 (patch)
tree55203f91ceba37004ac3bf816d173f64cfdc3e53 /drivers/thermal
parenta365105c685cad63e3c185c294373a7b81d3ea63 (diff)
downloadlinux-stable-e49a1e1ee078aee21006192076a8d93335e0daa9.tar.gz
linux-stable-e49a1e1ee078aee21006192076a8d93335e0daa9.tar.bz2
linux-stable-e49a1e1ee078aee21006192076a8d93335e0daa9.zip
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: c408b3d1d9bb ("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>
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/thermal_core.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 08de59369e94..e0ca631ac4c8 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -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);