mtd: parsers: scpart: add missing of_node_put() in scpart_parse()
authorYang Yingliang <yangyingliang@huawei.com>
Fri, 17 Jun 2022 01:40:08 +0000 (09:40 +0800)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Fri, 17 Jun 2022 06:29:50 +0000 (08:29 +0200)
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>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20220617014008.851583-1-yangyingliang@huawei.com
drivers/mtd/parsers/scpart.c

index bc40e25dc10593df2c71945024355db02cb38c74..02601bb33de4e4485ba043916b819a9c9d15fa79 100644 (file)
@@ -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);