[PATCH v2] mtd: Fix resource leaks in for_each_child_of_node() loops
From: Yang Rong
Date: Mon Jul 10 2023 - 04:50:41 EST
Ensure child node references are decremented properly in the error path.
Signed-off-by: Yang Rong <yangrong@xxxxxxxx>
---
v1: https://lore.kernel.org/all/20230621024517.1155-1-yangrong@xxxxxxxx/
The modifications made copared to the previous version are as follows:
1.I have changed the Subject to provide a clearer description of the issue.
2.I have simplified the commit message.
drivers/mtd/mtdcore.c | 1 +
1 file changed, 1 insertion(+)
mode change 100644 => 100755 drivers/mtd/mtdcore.c
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index e00b12aa5ec9..b02cb8b1a38d
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -591,6 +591,7 @@ static void mtd_check_of_node(struct mtd_info *mtd)
if (plen == mtd_name_len &&
!strncmp(mtd->name, pname + offset, plen)) {
mtd_set_of_node(mtd, mtd_dn);
+ of_node_put(mtd_dn);
break;
}
}
--
2.35.3