mtd: rawnand: vf610: Add of_node_put() before goto
authorNishka Dasgupta <nishkadg.linux@gmail.com>
Tue, 9 Jul 2019 17:08:37 +0000 (22:38 +0530)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Thu, 25 Jul 2019 12:21:44 +0000 (14:21 +0200)
Each iteration of for_each_available_child_of_node puts the previous
node, but in the case of a goto from the middle of the loop, there is no
put, thus causing a memory leak. Hence add an of_node_put before the
goto.
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
Reviewed-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
drivers/mtd/nand/raw/vf610_nfc.c

index e4fe8c4..6b399a7 100644 (file)
@@ -862,6 +862,7 @@ static int vf610_nfc_probe(struct platform_device *pdev)
                                dev_err(nfc->dev,
                                        "Only one NAND chip supported!\n");
                                err = -EINVAL;
+                               of_node_put(child);
                                goto err_disable_clk;
                        }