linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] thermal: core: Fix memory leak in the error path
       [not found] <20210317142215.GA2087@kadam>
@ 2021-03-19 20:22 ` Daniel Lezcano
  2021-04-15 12:04   ` [thermal: thermal/next] thermal/core: " thermal-bot for Daniel Lezcano
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Lezcano @ 2021-03-19 20:22 UTC (permalink / raw)
  To: daniel.lezcano
  Cc: kernel test robot, Dan Carpenter, Zhang Rui, Amit Kucheria,
	open list:THERMAL, open list

Fix the following error:

 smatch warnings:
 drivers/thermal/thermal_core.c:1020 __thermal_cooling_device_register() warn: possible memory leak of 'cdev'

by freeing the cdev when exiting the function in the error path.

Fixes: 584837618100 ("thermal/drivers/core: Use a char pointer for the cooling device name")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/thermal/thermal_core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index c8d4010940ef..3566fd291399 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1017,6 +1017,7 @@ __thermal_cooling_device_register(struct device_node *np,
 out_ida_remove:
 	ida_simple_remove(&thermal_cdev_ida, cdev->id);
 out_kfree_cdev:
+	kfree(cdev);
 	return ERR_PTR(ret);
 }
 
-- 
2.25.1


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

* [thermal: thermal/next] thermal/core: Fix memory leak in the error path
  2021-03-19 20:22 ` [PATCH] thermal: core: Fix memory leak in the error path Daniel Lezcano
@ 2021-04-15 12:04   ` thermal-bot for Daniel Lezcano
  0 siblings, 0 replies; 2+ messages in thread
From: thermal-bot for Daniel Lezcano @ 2021-04-15 12:04 UTC (permalink / raw)
  To: linux-pm
  Cc: kernel test robot, Dan Carpenter, Daniel Lezcano, rui.zhang, amitk

The following commit has been merged into the thermal/next branch of thermal:

Commit-ID:     d44616c6cc3e35eea03ecfe9040edfa2b486a059
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//d44616c6cc3e35eea03ecfe9040edfa2b486a059
Author:        Daniel Lezcano <daniel.lezcano@linaro.org>
AuthorDate:    Fri, 19 Mar 2021 21:22:57 +01:00
Committer:     Daniel Lezcano <daniel.lezcano@linaro.org>
CommitterDate: Thu, 15 Apr 2021 13:21:00 +02:00

thermal/core: Fix memory leak in the error path

Fix the following error:

 smatch warnings:
 drivers/thermal/thermal_core.c:1020 __thermal_cooling_device_register() warn: possible memory leak of 'cdev'

by freeing the cdev when exiting the function in the error path.

Fixes: 584837618100 ("thermal/drivers/core: Use a char pointer for the cooling device name")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20210319202257.890848-1-daniel.lezcano@linaro.org
---
 drivers/thermal/thermal_core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index c8d4010..3566fd2 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1017,6 +1017,7 @@ out_kfree_type:
 out_ida_remove:
 	ida_simple_remove(&thermal_cdev_ida, cdev->id);
 out_kfree_cdev:
+	kfree(cdev);
 	return ERR_PTR(ret);
 }
 

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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20210317142215.GA2087@kadam>
2021-03-19 20:22 ` [PATCH] thermal: core: Fix memory leak in the error path Daniel Lezcano
2021-04-15 12:04   ` [thermal: thermal/next] thermal/core: " thermal-bot for 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).