mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] nvmem: layouts: u-boot-env: Put cell nodes on registration failure
@ 2026-11-12  2:31 Zhu Jun
  2026-11-17 15:48 ` Srinivas Kandagatla
  0 siblings, 1 reply; 2+ messages in thread
From: Zhu Jun @ 2026-11-12  2:31 UTC (permalink / raw)
  To: rafal; +Cc: srini, linux-kernel, Zhu Jun

u_boot_env_parse_cells() takes a reference to each matching child node
before registering its cell. nvmem_add_one_cell() transfers that reference
to the cell on success, but does not release it if cell allocation or
initialization fails.

Drop the node reference when registration fails, preserving the existing
behavior of continuing with the remaining environment variables.

OpenAI Codex assisted with analysis and patch preparation.

Fixes: 7c8979b42b1a ("nvmem: u-boot-env: use nvmem_add_one_cell() nvmem subsystem helper")
Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
---
 drivers/nvmem/layouts/u-boot-env.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/nvmem/layouts/u-boot-env.c b/drivers/nvmem/layouts/u-boot-env.c
index 33ec2350386f..f4839571b794 100644
--- a/drivers/nvmem/layouts/u-boot-env.c
+++ b/drivers/nvmem/layouts/u-boot-env.c
@@ -78,7 +78,8 @@ static int u_boot_env_parse_cells(struct device *dev, struct nvmem_device *nvmem
 			info.read_post_process = u_boot_env_read_post_process_ethaddr;
 		}
 
-		nvmem_add_one_cell(nvmem, &info);
+		if (nvmem_add_one_cell(nvmem, &info))
+			of_node_put(info.np);
 	}
 
 	return 0;
-- 
2.51.0




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

* Re: [PATCH] nvmem: layouts: u-boot-env: Put cell nodes on registration failure
  2026-11-12  2:31 [PATCH] nvmem: layouts: u-boot-env: Put cell nodes on registration failure Zhu Jun
@ 2026-11-17 15:48 ` Srinivas Kandagatla
  0 siblings, 0 replies; 2+ messages in thread
From: Srinivas Kandagatla @ 2026-11-17 15:48 UTC (permalink / raw)
  To: Zhu Jun, rafal; +Cc: srini, linux-kernel



On 11/12/26 2:31 AM, Zhu Jun wrote:
> u_boot_env_parse_cells() takes a reference to each matching child node
> before registering its cell. nvmem_add_one_cell() transfers that reference
> to the cell on success, but does not release it if cell allocation or
> initialization fails.
> 
> Drop the node reference when registration fails, preserving the existing
> behavior of continuing with the remaining environment variables.
> 
> OpenAI Codex assisted with analysis and patch preparation.
> 
> Fixes: 7c8979b42b1a ("nvmem: u-boot-env: use nvmem_add_one_cell() nvmem subsystem helper")

Missing CC Stable

--srini
> Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
> ---
>  drivers/nvmem/layouts/u-boot-env.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/nvmem/layouts/u-boot-env.c b/drivers/nvmem/layouts/u-boot-env.c
> index 33ec2350386f..f4839571b794 100644
> --- a/drivers/nvmem/layouts/u-boot-env.c
> +++ b/drivers/nvmem/layouts/u-boot-env.c
> @@ -78,7 +78,8 @@ static int u_boot_env_parse_cells(struct device *dev, struct nvmem_device *nvmem
>  			info.read_post_process = u_boot_env_read_post_process_ethaddr;
>  		}
>  
> -		nvmem_add_one_cell(nvmem, &info);
> +		if (nvmem_add_one_cell(nvmem, &info))
> +			of_node_put(info.np);
>  	}
>  
>  	return 0;


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

end of thread, other threads:[~2026-11-17 15:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-12  2:31 [PATCH] nvmem: layouts: u-boot-env: Put cell nodes on registration failure Zhu Jun
2026-11-17 15:48 ` 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®