[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20210319202257.890848-1-daniel.lezcano@linaro.org>
Date: Fri, 19 Mar 2021 21:22:57 +0100
From: Daniel Lezcano <daniel.lezcano@...aro.org>
To: daniel.lezcano@...aro.org
Cc: kernel test robot <lkp@...el.com>,
Dan Carpenter <dan.carpenter@...cle.com>,
Zhang Rui <rui.zhang@...el.com>,
Amit Kucheria <amitk@...nel.org>,
linux-pm@...r.kernel.org (open list:THERMAL),
linux-kernel@...r.kernel.org (open list)
Subject: [PATCH] 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@...el.com>
Reported-by: Dan Carpenter <dan.carpenter@...cle.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@...aro.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
Powered by blists - more mailing lists