Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: mpc5121_nfc: fix memory leak on error path

Add a call to of_node_put in the error handling code following a call to
of_find_compatible_node.

Signed-off-by: Julia Lawall <julia@diku.dk>
Acked-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

authored by

Julia Lawall and committed by
David Woodhouse
cf363518 9d8b1043

+5 -2
+5 -2
drivers/mtd/nand/mpc5121_nfc.c
··· 568 568 uint rcw_width; 569 569 uint rcwh; 570 570 uint romloc, ps; 571 + int ret = 0; 571 572 572 573 rmnode = of_find_compatible_node(NULL, NULL, "fsl,mpc5121-reset"); 573 574 if (!rmnode) { ··· 580 579 rm = of_iomap(rmnode, 0); 581 580 if (!rm) { 582 581 dev_err(prv->dev, "Error mapping reset module node!\n"); 583 - return -EBUSY; 582 + ret = -EBUSY; 583 + goto out; 584 584 } 585 585 586 586 rcwh = in_be32(&rm->rcwhr); ··· 630 628 rcw_width * 8, rcw_pagesize, 631 629 rcw_sparesize); 632 630 iounmap(rm); 631 + out: 633 632 of_node_put(rmnode); 634 - return 0; 633 + return ret; 635 634 } 636 635 637 636 /* Free driver resources */