thermal/drivers/devfreq_cooling: Fix error return if kasprintf returns NULL
Subsystems (2)
PATCH 1/1 thermal/drivers/devfreq_cooling: Fix error return if kasprintf returns NULL
From: Colin Ian King <[email protected]>
Currently when kasprintf fails and returns NULL, the error return -ENOMEM is being assigned to cdev instead of err causing the return via the label remove_qos_re to return the incorrect error code. Fix this by explicitly setting err before taking the error return path.
Addresses-Coverity: ("Unused valued")
--- drivers/thermal/devfreq_cooling.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/thermal/devfreq_cooling.c +3 -2
@@ -402,10 +402,11 @@ of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,if (err <0 ) goto free_table; - cdev =ERR_PTR (-ENOMEM ); name =kasprintf (GFP_KERNEL ,"devfreq-%s" ,dev_name (dev)); -if (!name) +if (!name) { + err = -ENOMEM ; goto remove_qos_req; + } cdev =thermal_of_cooling_device_register (np, name, dfc, &devfreq_cooling_ops);
Signature · 1 line
2.30.2
Hi Colin,
Quoted 11 lines · Colin King
From: Colin Ian King <[email protected]>
Currently when kasprintf fails and returns NULL, the error return
-ENOMEMis being assigned to cdev instead of err causing the return via the labelremove_qos_reto return the incorrect error code. Fix this by explicitly setting err before taking the error return path.Addresses-Coverity: ("Unused valued")
Fixes f8d354e821b2 ("thermal/drivers/devfreq_cooling: Use device name instead of auto-numbering")Signed-off-by Colin Ian King <[email protected]>---
Thanks for your patch. It was already fixed after being reported by kbuild-test.
-- Daniel
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog