Re: [PATCH] mtd: ubi: nvmem: Fix device_node leak in ubi_nvmem_add()

From: Daniel Golle

Date: Tue Oct 27 2026 - 05:19:00 EST


On Tue, Oct 27, 2026 at 02:45:07PM +0530, Vishal Satle wrote:
> ubi_nvmem_add() calls of_get_child_by_name() to verify that the UBI
> volume device node contains an "nvmem-layout" subnode.
> of_get_child_by_name() returns a pointer to the child device_node
> with its reference count incremented.
>
> Because the returned pointer was only evaluated as a boolean condition
> and not retained or put, the reference count of the "nvmem-layout" node
> was leaked whenever an NVMEM-enabled UBI volume was registered.
>
> Assign the child node to a local variable and release it with
> of_node_put() once existence has been validated.
>
> Fixes: 34a5d8525b6a ("mtd: ubi: add NVMEM support")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Vishal Satle <vishalsatleit24@xxxxxxxxx>

Thanks for fixing this.

Reviewed-by: Daniel Golle <daniel@xxxxxxxxxxxxxx>