Skip to contentSkip to conversation

drivers/thermal: fix potential memleak in error branch

PATCH Superseded Bernard Zhao 1 participant 1 message Nov 2, 2020 Thermal

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/thermal: fix potential memleak in error branch

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

---
 drivers/thermal/thermal_core.c | 1 +
 1 file changed, 1 insertion(+)
drivers/thermal/thermal_core.c +1 -0
index 3d1e0033bf3e..e4bee15dfa1f 100644
@@ -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);
 	}
 
Signature · 1 line
2.29.0