mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] nvmem: core: fix memory leak in nvmem_register() on error path
@ 2025-06-15 13:52 Alok Tiwari
  2025-06-15 13:52 ` [PATCH 2/2] nvmem: core: Fix typos in comments and MODULE_AUTHOR strings Alok Tiwari
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alok Tiwari @ 2025-06-15 13:52 UTC (permalink / raw)
  To: srini, linux-kernel; +Cc: alok.a.tiwari, darren.kenny

Ensure that the allocated nvmem structure is freed if device
registration return error code.
The missing kfree() caused a memory leak when nvmem_register()
exited via err_put_device label.

Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
---
 drivers/nvmem/core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index fd2a9698d1c9..3203524ad49f 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -1044,6 +1044,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
 		nvmem_sysfs_remove_compat(nvmem, config);
 err_put_device:
 	put_device(&nvmem->dev);
+	kfree(nvmem);
 
 	return ERR_PTR(rval);
 }
-- 
2.47.1


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

end of thread, other threads:[~2025-06-27 12:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-15 13:52 [PATCH 1/2] nvmem: core: fix memory leak in nvmem_register() on error path Alok Tiwari
2025-06-15 13:52 ` [PATCH 2/2] nvmem: core: Fix typos in comments and MODULE_AUTHOR strings Alok Tiwari
2025-06-16 12:44 ` [PATCH 1/2] nvmem: core: fix memory leak in nvmem_register() on error path ALOK TIWARI
2025-06-27 12:08 ` (subset) " Srinivas Kandagatla

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®