Skip to content

Commit 560c045

Browse files
Demon000gregkh
authored andcommitted
mtd: parsers: ofpart: call of_node_put() only in ofpart_fail path
[ Upstream commit 0c87dea ] 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: ebd5a74 ("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent cca2c08 commit 560c045

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/mtd/parsers/ofpart_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,11 @@ static int parse_fixed_partitions(struct mtd_info *master,
191191
ofpart_fail:
192192
pr_err("%s: error parsing ofpart partition %pOF (%pOF)\n",
193193
master->name, pp, mtd_node);
194+
of_node_put(pp);
194195
ret = -EINVAL;
195196
ofpart_none:
196197
if (dedicated)
197198
of_node_put(ofpart_node);
198-
of_node_put(pp);
199199
kfree(parts);
200200
return ret;
201201
}

0 commit comments

Comments
 (0)