thermal/core: fix error code in __thermal_cooling_device_register()
Subsystems (2)
PATCH 1/1 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 <[email protected]>
--- drivers/thermal/thermal_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/thermal/thermal_core.c +2 -1
@@ -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);
Signature · 1 line
2.35.1
Quoted 15 lines · Dan Carpenter
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 <[email protected]>--- drivers/thermal/thermal_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/thermal/thermal_core.c +0
-0
drivers/thermal/thermal_core.c __thermal_cooling_device_register(struct device_node *np,
Quoted 10 lines
drivers/thermal/thermal_core.c +2
-2@@ -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); --
Applied, thanks!
Quoted 14 lines · Dan Carpenter
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 <[email protected]>--- drivers/thermal/thermal_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/thermal/thermal_core.c +0
-0
drivers/thermal/thermal_core.c __thermal_cooling_device_register(struct device_node *np, · line 899
Quoted 9 lines
drivers/thermal/thermal_core.c +2
-1@@ -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);
Bad mistake.
Acked-by Viresh Kumar <[email protected]>
Signature · 1 line
viresh