Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mtd: parsers: ofpart: call of_node_put() only in ofpart_fail path

ofpart_none can only be reached after the for_each_child_of_node() loop
finishes. for_each_child_of_node() correctly calls of_node_put() for all
device nodes it iterates over as long as we don't break or jump out of
the loop.

Calling of_node_put() inside the ofpart_none path will wrongly decrement
the ref count of the last node in the for_each_child_of_node() loop.

Move the call to of_node_put() under the ofpart_fail label to fix this.

Fixes: ebd5a74db74e ("mtd: ofpart: Check availability of reg property instead of name property")
Signed-off-by: Cosmin Tanislav <cosmin-gabriel.tanislav.xa@renesas.com>
Tested-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

authored by

Cosmin Tanislav and committed by
Miquel Raynal
0c87dea1 54f955ba

+1 -1
+1 -1
drivers/mtd/parsers/ofpart_core.c
··· 195 195 ofpart_fail: 196 196 pr_err("%s: error parsing ofpart partition %pOF (%pOF)\n", 197 197 master->name, pp, mtd_node); 198 + of_node_put(pp); 198 199 ret = -EINVAL; 199 200 ofpart_none: 200 201 if (dedicated) 201 202 of_node_put(ofpart_node); 202 - of_node_put(pp); 203 203 kfree(parts); 204 204 return ret; 205 205 }