Skip to content

Commit

Permalink
mtd: parsers: ofpart: Fix refcount leak in bcm4908_partitions_fw_offset
Browse files Browse the repository at this point in the history
[ Upstream commit e607879 ]

of_find_node_by_path() returns a node pointer with refcount incremented,
we should use of_node_put() on it when not need anymore.
Add missing of_node_put() to avoid refcount leak.

Fixes: bb17230 ("mtd: parsers: ofpart: support BCM4908 fixed partitions")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20220605070726.5979-1-linmq006@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Yuuoniy authored and gregkh committed Aug 17, 2022
1 parent 8ea6075 commit 7624754
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/mtd/parsers/ofpart_bcm4908.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ static long long bcm4908_partitions_fw_offset(void)
err = kstrtoul(s + len + 1, 0, &offset);
if (err) {
pr_err("failed to parse %s\n", s + len + 1);
of_node_put(root);
return err;
}

of_node_put(root);
return offset << 10;
}

of_node_put(root);
return -ENOENT;
}

Expand Down

0 comments on commit 7624754

Please sign in to comment.