mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] peci: fix potential memory leak in devm_adev_add()
@ 2022-07-04 12:59 Jianglei Nie
  2022-07-05 10:18 ` Winiarska, Iwona
  0 siblings, 1 reply; 2+ messages in thread
From: Jianglei Nie @ 2022-07-04 12:59 UTC (permalink / raw)
  To: iwona.winiarska; +Cc: openbmc, linux-kernel, Jianglei Nie

devm_adev_add() allocates a memory chunk for "adev" and "adev->name"
with adev_alloc(). When auxiliary_device_add() fails, the function calls
auxiliary_device_uninit(), which doesn't release the allocated "adev"
and "adev->name", thus leading to a memory leak bug.

We should call adev_release() instead of auxiliary_device_uninit() to
release the "adev" and "adev->name".

Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
---
 drivers/peci/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/peci/cpu.c b/drivers/peci/cpu.c
index 68eb61c65d34..de865997ccde 100644
--- a/drivers/peci/cpu.c
+++ b/drivers/peci/cpu.c
@@ -248,7 +248,7 @@ static int devm_adev_add(struct device *dev, int idx)
 
 	ret = auxiliary_device_add(adev);
 	if (ret) {
-		auxiliary_device_uninit(adev);
+		adev_release(&adev->dev);
 		return ret;
 	}
 
-- 
2.25.1


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

end of thread, other threads:[~2022-07-05 10:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-04 12:59 [PATCH] peci: fix potential memory leak in devm_adev_add() Jianglei Nie
2022-07-05 10:18 ` Winiarska, Iwona

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®