diff mbox series

[-next] mtd: parsers: scpart: add missing of_node_put() in scpart_parse()

Message ID 20220617014008.851583-1-yangyingliang@huawei.com
State Accepted
Headers show
Series [-next] mtd: parsers: scpart: add missing of_node_put() in scpart_parse() | expand

Commit Message

Yang Yingliang June 17, 2022, 1:40 a.m. UTC
of_get_child_by_name() will increase the refcount of 'ofpart_node',
so add of_node_put() after using it to avoid refcount leak.

Fixes: 9b78ef0c7997 ("mtd: parsers: add support for Sercomm partitions")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/mtd/parsers/scpart.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Miquel Raynal June 17, 2022, 6:31 a.m. UTC | #1
On Fri, 2022-06-17 at 01:40:08 UTC, Yang Yingliang wrote:
> of_get_child_by_name() will increase the refcount of 'ofpart_node',
> so add of_node_put() after using it to avoid refcount leak.
> 
> Fixes: 9b78ef0c7997 ("mtd: parsers: add support for Sercomm partitions")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>

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

Miquel
diff mbox series

Patch

diff --git a/drivers/mtd/parsers/scpart.c b/drivers/mtd/parsers/scpart.c
index bc40e25dc105..02601bb33de4 100644
--- a/drivers/mtd/parsers/scpart.c
+++ b/drivers/mtd/parsers/scpart.c
@@ -219,6 +219,7 @@  static int scpart_parse(struct mtd_info *master,
 	of_node_put(pp);
 
 free:
+	of_node_put(ofpart_node);
 	kfree(scpart_map);
 	if (res <= 0)
 		kfree(parts);