Commit 0c87dea1 authored by Cosmin Tanislav's avatar Cosmin Tanislav Committed by Miquel Raynal
Browse files

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: ebd5a74d ("mtd: ofpart: Check availability of reg property instead of name property")
Signed-off-by: default avatarCosmin Tanislav <cosmin-gabriel.tanislav.xa@renesas.com>
Tested-by: default avatarTommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
parent 54f955ba
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -195,11 +195,11 @@ static int parse_fixed_partitions(struct mtd_info *master,
ofpart_fail:
	pr_err("%s: error parsing ofpart partition %pOF (%pOF)\n",
	       master->name, pp, mtd_node);
	of_node_put(pp);
	ret = -EINVAL;
ofpart_none:
	if (dedicated)
		of_node_put(ofpart_node);
	of_node_put(pp);
	kfree(parts);
	return ret;
}