Skip to contentSkip to conversation

mtd: Fix resource leaks in for_each_child_of_node() loops

PATCH In review Yang Rong 2 participants 2 messages Jul 10, 2023 Memory technology devices (MTD)

lore
Share & tools
lore

Yang Rong

author
#0 lore raw

PATCH v2 1/1 mtd: Fix resource leaks in for_each_child_of_node() loops

Ensure child node references are decremented properly in the error path.

---
v1: https://lore.kernel.org/all/[email protected]/
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
drivers/mtd/mtdcore.c +1 -0
index e00b12aa5ec9..b02cb8b1a38d
@@ -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;
 		}
 	}
Signature · 1 line
2.35.3
#1 lore raw

Would a subject like “[PATCH v3] mtd: core: Fix resource leak in a for_each_child_of_node() loop” be more appropriate?

Quoted 1 line

Ensure child node references are decremented properly in the error path.

How do you think about the following wording variant?

Ensure child node references are properly decremented in the error path of this function implementation.

Would you like to add the tag “Fixes” because of the completion of the exception handling?

Regards,
Markus

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/