linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: parsers: ofpart: Fix refcount leak in bcm4908_partitions_fw_offset
@ 2022-06-05  7:07 Miaoqian Lin
  2022-06-09 12:42 ` Miquel Raynal
  0 siblings, 1 reply; 2+ messages in thread
From: Miaoqian Lin @ 2022-06-05  7:07 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Miaoqian Lin, Rafał Miłecki, linux-mtd, linux-kernel

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: bb17230c61a6 ("mtd: parsers: ofpart: support BCM4908 fixed partitions")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/mtd/parsers/ofpart_bcm4908.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mtd/parsers/ofpart_bcm4908.c b/drivers/mtd/parsers/ofpart_bcm4908.c
index 0eddef4c198e..bb072a0940e4 100644
--- a/drivers/mtd/parsers/ofpart_bcm4908.c
+++ b/drivers/mtd/parsers/ofpart_bcm4908.c
@@ -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;
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mtd: parsers: ofpart: Fix refcount leak in bcm4908_partitions_fw_offset
  2022-06-05  7:07 [PATCH] mtd: parsers: ofpart: Fix refcount leak in bcm4908_partitions_fw_offset Miaoqian Lin
@ 2022-06-09 12:42 ` Miquel Raynal
  0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2022-06-09 12:42 UTC (permalink / raw)
  To: Miaoqian Lin, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Rafał Miłecki, linux-mtd,
	linux-kernel

On Sun, 2022-06-05 at 07:07:23 UTC, Miaoqian Lin wrote:
> 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: bb17230c61a6 ("mtd: parsers: ofpart: support BCM4908 fixed partitions")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-09 12:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-05  7:07 [PATCH] mtd: parsers: ofpart: Fix refcount leak in bcm4908_partitions_fw_offset Miaoqian Lin
2022-06-09 12:42 ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).