All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvmem: core: Fix a resource leak on error in nvmem_add_cells_from_of()
@ 2020-12-19 10:55 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2020-12-19 10:55 UTC (permalink / raw)
  To: Srinivas Kandagatla; +Cc: Greg Kroah-Hartman, linux-kernel, kernel-janitors

This doesn't call of_node_put() on the error path so it leads to a
memory leak.

Fixes: 0749aa25af82 ("nvmem: core: fix regression in of_nvmem_cell_get()")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
The kfree_const() could just be replaced with kfree().  Someone got over
excited converting things from kfree() to kfree_const().

 drivers/nvmem/core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 177f5bf27c6d..68ae6f24b57f 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -713,6 +713,7 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem)
 				cell->name, nvmem->stride);
 			/* Cells already added will be freed later. */
 			kfree_const(cell->name);
+			of_node_put(cell->np);
 			kfree(cell);
 			return -EINVAL;
 		}
-- 
2.29.2


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

* [PATCH] nvmem: core: Fix a resource leak on error in nvmem_add_cells_from_of()
@ 2020-12-19 10:55 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2020-12-19 10:55 UTC (permalink / raw)
  To: Srinivas Kandagatla; +Cc: Greg Kroah-Hartman, linux-kernel, kernel-janitors

This doesn't call of_node_put() on the error path so it leads to a
memory leak.

Fixes: 0749aa25af82 ("nvmem: core: fix regression in of_nvmem_cell_get()")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
The kfree_const() could just be replaced with kfree().  Someone got over
excited converting things from kfree() to kfree_const().

 drivers/nvmem/core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 177f5bf27c6d..68ae6f24b57f 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -713,6 +713,7 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem)
 				cell->name, nvmem->stride);
 			/* Cells already added will be freed later. */
 			kfree_const(cell->name);
+			of_node_put(cell->np);
 			kfree(cell);
 			return -EINVAL;
 		}
-- 
2.29.2

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

* Re: [PATCH] nvmem: core: Fix a resource leak on error in nvmem_add_cells_from_of()
  2020-12-19 10:55 ` Dan Carpenter
@ 2021-01-05 16:23   ` Srinivas Kandagatla
  -1 siblings, 0 replies; 4+ messages in thread
From: Srinivas Kandagatla @ 2021-01-05 16:23 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Greg Kroah-Hartman, linux-kernel, kernel-janitors



On 19/12/2020 10:55, Dan Carpenter wrote:
> This doesn't call of_node_put() on the error path so it leads to a
> memory leak.
> 
> Fixes: 0749aa25af82 ("nvmem: core: fix regression in of_nvmem_cell_get()")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied, thanks

--srini
> ---
> The kfree_const() could just be replaced with kfree().  Someone got over
> excited converting things from kfree() to kfree_const().
> 
>   drivers/nvmem/core.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index 177f5bf27c6d..68ae6f24b57f 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -713,6 +713,7 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem)
>   				cell->name, nvmem->stride);
>   			/* Cells already added will be freed later. */
>   			kfree_const(cell->name);
> +			of_node_put(cell->np);
>   			kfree(cell);
>   			return -EINVAL;
>   		}
> 

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

* Re: [PATCH] nvmem: core: Fix a resource leak on error in nvmem_add_cells_from_of()
@ 2021-01-05 16:23   ` Srinivas Kandagatla
  0 siblings, 0 replies; 4+ messages in thread
From: Srinivas Kandagatla @ 2021-01-05 16:23 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Greg Kroah-Hartman, linux-kernel, kernel-janitors



On 19/12/2020 10:55, Dan Carpenter wrote:
> This doesn't call of_node_put() on the error path so it leads to a
> memory leak.
> 
> Fixes: 0749aa25af82 ("nvmem: core: fix regression in of_nvmem_cell_get()")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied, thanks

--srini
> ---
> The kfree_const() could just be replaced with kfree().  Someone got over
> excited converting things from kfree() to kfree_const().
> 
>   drivers/nvmem/core.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index 177f5bf27c6d..68ae6f24b57f 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -713,6 +713,7 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem)
>   				cell->name, nvmem->stride);
>   			/* Cells already added will be freed later. */
>   			kfree_const(cell->name);
> +			of_node_put(cell->np);
>   			kfree(cell);
>   			return -EINVAL;
>   		}
> 

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

end of thread, other threads:[~2021-01-05 16:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-19 10:55 [PATCH] nvmem: core: Fix a resource leak on error in nvmem_add_cells_from_of() Dan Carpenter
2020-12-19 10:55 ` Dan Carpenter
2021-01-05 16:23 ` Srinivas Kandagatla
2021-01-05 16:23   ` Srinivas Kandagatla

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.