]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
mtd: parsers: ofpart: fix OF node refcount leak in parse_fixed_partitions()
authorWeigang He <geoffreyhe2@gmail.com>
Fri, 23 Jan 2026 05:26:08 +0000 (05:26 +0000)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Thu, 29 Jan 2026 19:10:34 +0000 (20:10 +0100)
commit7cce81df7d26d44123bd7620715c8349d96793d7
tree39e1f0cd6bb99d8678be626fc695a89e3d2c5927
parent68cd8ef484521a01826735518f173c4ae3900eff
mtd: parsers: ofpart: fix OF node refcount leak in parse_fixed_partitions()

of_get_child_by_name() returns a node pointer with refcount incremented,
which must be released with of_node_put() when done. However, in
parse_fixed_partitions(), when dedicated is true (i.e., a "partitions"
subnode was found), the ofpart_node obtained from of_get_child_by_name()
is never released on any code path.

Add of_node_put(ofpart_node) calls on all exit paths when dedicated is
true to fix the reference count leak.

This bug was detected by our static analysis tool.

Fixes: 562b4e91d3b2 ("mtd: parsers: ofpart: fix parsing subpartitions")
Signed-off-by: Weigang He <geoffreyhe2@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
drivers/mtd/parsers/ofpart_core.c