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

* [PATCH 2/2] nvmem: core: Fix typos in comments and MODULE_AUTHOR strings
  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 ` 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
  2 siblings, 0 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

This patch fixes minor typo issues for nvmem-core.c:
 Corrects "form" to "from" in multiple function descriptions.
 Fixes missing closing angle brackets in MODULE_AUTHOR entries.

These changes improve readability and formatting consistency.

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

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 3203524ad49f..d0b956133c61 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -1264,7 +1264,7 @@ void nvmem_device_put(struct nvmem_device *nvmem)
 EXPORT_SYMBOL_GPL(nvmem_device_put);
 
 /**
- * devm_nvmem_device_get() - Get nvmem device of device form a given id
+ * devm_nvmem_device_get() - Get nvmem device of device from a given id
  *
  * @dev: Device that requests the nvmem device.
  * @id: name id for the requested nvmem device.
@@ -1492,7 +1492,7 @@ EXPORT_SYMBOL_GPL(of_nvmem_cell_get);
 #endif
 
 /**
- * nvmem_cell_get() - Get nvmem cell of device form a given cell name
+ * nvmem_cell_get() - Get nvmem cell of device from a given cell name
  *
  * @dev: Device that requests the nvmem cell.
  * @id: nvmem cell name to get (this corresponds with the name from the
@@ -1527,7 +1527,7 @@ static void devm_nvmem_cell_release(struct device *dev, void *res)
 }
 
 /**
- * devm_nvmem_cell_get() - Get nvmem cell of device form a given id
+ * devm_nvmem_cell_get() - Get nvmem cell of device from a given id
  *
  * @dev: Device that requests the nvmem cell.
  * @id: nvmem cell name id to get.
@@ -2195,6 +2195,6 @@ static void __exit nvmem_exit(void)
 subsys_initcall(nvmem_init);
 module_exit(nvmem_exit);
 
-MODULE_AUTHOR("Srinivas Kandagatla <srinivas.kandagatla@linaro.org");
-MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com");
+MODULE_AUTHOR("Srinivas Kandagatla <srinivas.kandagatla@linaro.org>");
+MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com>");
 MODULE_DESCRIPTION("nvmem Driver Core");
-- 
2.47.1


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

* Re: [PATCH 1/2] nvmem: core: fix memory leak in nvmem_register() on error path
  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 ` ALOK TIWARI
  2025-06-27 12:08 ` (subset) " Srinivas Kandagatla
  2 siblings, 0 replies; 4+ messages in thread
From: ALOK TIWARI @ 2025-06-16 12:44 UTC (permalink / raw)
  To: srini, linux-kernel; +Cc: darren.kenny



On 15-06-2025 19:22, Alok Tiwari wrote:
> 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);
>   }

Please ignore this patch. it is not required.
nvmem_release already handles the cleanup properly.

Thanks,
Alok

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

* Re: (subset) [PATCH 1/2] nvmem: core: fix memory leak in nvmem_register() on error path
  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 ` Srinivas Kandagatla
  2 siblings, 0 replies; 4+ messages in thread
From: Srinivas Kandagatla @ 2025-06-27 12:08 UTC (permalink / raw)
  To: linux-kernel, Alok Tiwari; +Cc: darren.kenny


On Sun, 15 Jun 2025 06:52:07 -0700, Alok Tiwari wrote:
> 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.
> 
> 

Applied, thanks!

[2/2] nvmem: core: Fix typos in comments and MODULE_AUTHOR strings
      commit: 98addb97db5d86ad18c831241c03f180d269438f

Best regards,
-- 
Srinivas Kandagatla <srini@kernel.org>


^ 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®