linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] thermal/drivers/devfreq_cooling: Fix error return if kasprintf returns NULL
@ 2021-03-25 17:21 Colin King
  2021-04-04 20:12 ` Daniel Lezcano
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2021-03-25 17:21 UTC (permalink / raw)
  To: Zhang Rui, Daniel Lezcano, Amit Kucheria, Lukasz Luba, linux-pm
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

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")
Fixes: f8d354e821b2 ("thermal/drivers/devfreq_cooling: Use device name instead of auto-numbering")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/thermal/devfreq_cooling.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/devfreq_cooling.c b/drivers/thermal/devfreq_cooling.c
index fb250ac16f50..2c7e9e9cfbe1 100644
--- a/drivers/thermal/devfreq_cooling.c
+++ b/drivers/thermal/devfreq_cooling.c
@@ -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);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH][next] thermal/drivers/devfreq_cooling: Fix error return if kasprintf returns NULL
  2021-03-25 17:21 [PATCH][next] thermal/drivers/devfreq_cooling: Fix error return if kasprintf returns NULL Colin King
@ 2021-04-04 20:12 ` Daniel Lezcano
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Lezcano @ 2021-04-04 20:12 UTC (permalink / raw)
  To: Colin King, Zhang Rui, Amit Kucheria, Lukasz Luba, linux-pm
  Cc: kernel-janitors, linux-kernel


Hi Colin,


On 25/03/2021 18:21, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> 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")
> Fixes: f8d354e821b2 ("thermal/drivers/devfreq_cooling: Use device name instead of auto-numbering")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---

Thanks for your patch. It was already fixed after being reported by
kbuild-test.

  -- Daniel



-- 
<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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-04 20:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-25 17:21 [PATCH][next] thermal/drivers/devfreq_cooling: Fix error return if kasprintf returns NULL Colin King
2021-04-04 20:12 ` Daniel Lezcano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).