Skip to contentSkip to conversation

mtd: ubi: nvmem: put the nvmem-layout node after the check

PATCH New Cong Nguyen 1 participant 1 message Nov 29

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: ubi: nvmem: put the nvmem-layout node after the check

ubi_nvmem_add() calls of_get_child_by_name() only to see whether the volume has an "nvmem-layout" node, and never drops the reference it gets.

Put the node right after the check.

Fixes 3ce485803da1 ("mtd: ubi: provide NVMEM layer over UBI volumes")
---
 drivers/mtd/ubi/nvmem.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/mtd/ubi/nvmem.c +4 -1
index 2dade9727cf2..05bf71f66b34 100644
@@ -61,6 +61,7 @@ static int ubi_nvmem_reg_read(void *priv, unsigned int from,
 static int ubi_nvmem_add(struct ubi_volume_info *vi)
 {
 	struct device_node *np = dev_of_node(vi->dev);
+	struct device_node *layout;
 	struct nvmem_config config = {};
 	struct ubi_nvmem *unv;
 	int ret;
@@ -68,8 +69,10 @@ static int ubi_nvmem_add(struct ubi_volume_info *vi)
 	if (!np)
 		return 0;
 
-	if (!of_get_child_by_name(np, "nvmem-layout"))
+	layout = of_get_child_by_name(np, "nvmem-layout");
+	if (!layout)
 		return 0;
+	of_node_put(layout);
 
 	if (WARN_ON_ONCE(vi->usable_leb_size <= 0) ||
 	    WARN_ON_ONCE(vi->size <= 0))
Signature · 1 line
2.25.1