ll_temac: fix memory leak
Subsystems (3)
PATCH 2/4 ll_temac: fix memory leak
If of_iomap() or irq_of_parse_and_map() fail then np must be freed.
Signed-off-by Kulikov Vasiliy <[email protected]>
--- drivers/net/ll_temac_main.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/net/ll_temac_main.c +4 -1
@@ -999,19 +999,22 @@ temac_of_probe(struct of_device *op, const struct of_device_id *match)dev_dbg (&op->dev,"MEM base: %p\n" , lp->sdma_regs); }else {dev_err (&op->dev,"unable to map DMA registers\n" ); +of_node_put (np); goto err_iounmap; } } lp->rx_irq =irq_of_parse_and_map (np,0 ); lp->tx_irq =irq_of_parse_and_map (np,1 ); + +of_node_put (np);/* Finished with the DMA node; drop the reference */ +if ((lp->rx_irq =NO_IRQ ) || (lp->tx_irq =NO_IRQ )) {dev_err (&op->dev,"could not determine irqs\n" ); rc = -ENOMEM ; goto err_iounmap_2; } -of_node_put (np);/* Finished with the DMA node; drop the reference */ /* Retrieve the MAC address */ addr =of_get_property (op->dev.of_node,"local-mac-address" , &size);
Signature · 1 line
1.7.0.4
Quoted 3 lines · Kulikov Vasiliy
If
of_iomap()orirq_of_parse_and_map()fail then np must be freed.Signed-off-by Kulikov Vasiliy <[email protected]>
Looks correct to me.
g.
Quoted 36 lines
---
drivers/net/ll_temac_main.c | 5 ++++-1 files changed, 4 insertions(+), 1 deletions(-)drivers/net/ll_temac_main.c +4
-2@@ -999,19 +999,22 @@ temac_of_probe(struct of_device *op, const struct of_device_id *match) dev_dbg(&op->dev, "MEM base: %p\n", lp->sdma_regs); } else { dev_err(&op->dev, "unable to map DMA registers\n"); + of_node_put(np); goto err_iounmap; } } lp->rx_irq = irq_of_parse_and_map(np, 0); lp->tx_irq = irq_of_parse_and_map(np, 1); + + of_node_put(np); /* Finished with the DMA node; drop the reference */ + if ((lp->rx_irq = NO_IRQ) || (lp->tx_irq = NO_IRQ)) { dev_err(&op->dev, "could not determine irqs\n"); rc = -ENOMEM; goto err_iounmap_2; } - of_node_put(np); /* Finished with the DMA node; drop the reference */ /* Retrieve the MAC address */ addr = of_get_property(op->dev.of_node, "local-mac-address", &size); --1.7.0.4
Signature · 6 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd. -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Kulikov Vasiliy <[email protected]>
Date: Thu, 8 Jul 2010 16:10:03 +0400
Quoted 3 lines
If
of_iomap()orirq_of_parse_and_map()fail then np must be freed.Signed-off-by Kulikov Vasiliy <[email protected]>
Applied, thanks.