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

Daniel Golle daniel at makrotopia.org
Tue Oct 27 02:18:38 PDT 2026


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 at vger.kernel.org
> Signed-off-by: Vishal Satle <vishalsatleit24 at gmail.com>

Thanks for fixing this.

Reviewed-by: Daniel Golle <daniel at makrotopia.org>



More information about the linux-mtd mailing list