mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drivers/thermal: fix potential memleak in error branch
@ 2020-11-02  2:11 Bernard Zhao
  0 siblings, 0 replies; only message in thread
From: Bernard Zhao @ 2020-11-02  2:11 UTC (permalink / raw)
  To: Zhang Rui, Daniel Lezcano, Amit Kucheria, linux-pm, linux-kernel
  Cc: opensource.kernel, Bernard Zhao

Function __thermal_cooling_device_register, when device_register
failed, cdev is not free after error value return, this may
bring in potential memleak.

Signed-off-by: Bernard Zhao <bernard@vivo.com>
---
 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 3d1e0033bf3e..e4bee15dfa1f 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1125,6 +1125,7 @@ __thermal_cooling_device_register(struct device_node *np,
 	if (result) {
 		ida_simple_remove(&thermal_cdev_ida, cdev->id);
 		put_device(&cdev->device);
+		kfree(cdev);
 		return ERR_PTR(result);
 	}
 
-- 
2.29.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-11-02  2:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-02  2:11 [PATCH] drivers/thermal: fix potential memleak in error branch Bernard Zhao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®