linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] 82xx: kmalloc failure ignored in ep8248e_mdio_probe()
@ 2009-09-09 14:49 Roel Kluin
  2009-09-09 18:46 ` Scott Wood
  2009-09-24 18:19 ` Kumar Gala
  0 siblings, 2 replies; 3+ messages in thread
From: Roel Kluin @ 2009-09-09 14:49 UTC (permalink / raw)
  To: benh, paulus, linuxppc-dev, Andrew Morton

Prevent NULL dereference if kmalloc() fails. Also clean up if
of_mdiobus_register() returns an error.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
Found with sed: http://kernelnewbies.org/roelkluin

Please review.

diff --git a/arch/powerpc/platforms/82xx/ep8248e.c b/arch/powerpc/platforms/82xx/ep8248e.c
index 51fcae4..f9aee18 100644
--- a/arch/powerpc/platforms/82xx/ep8248e.c
+++ b/arch/powerpc/platforms/82xx/ep8248e.c
@@ -132,12 +132,25 @@ static int __devinit ep8248e_mdio_probe(struct of_device *ofdev,
 		return -ENOMEM;
 
 	bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
+	if (bus->irq == NULL) {
+		ret = -ENOMEM;
+		goto err_free_bus;
+	}
 
 	bus->name = "ep8248e-mdio-bitbang";
 	bus->parent = &ofdev->dev;
 	snprintf(bus->id, MII_BUS_ID_SIZE, "%x", res.start);
 
-	return of_mdiobus_register(bus, ofdev->node);
+	ret = of_mdiobus_register(bus, ofdev->node);
+	if (ret)
+		goto err_free_irq;
+
+	return 0;
+err_free_irq:
+	kfree(bus->irq);
+err_free_bus:
+	free_mdio_bitbang(bus);
+	return ret;
 }
 
 static int ep8248e_mdio_remove(struct of_device *ofdev)

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-09-24 18:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-09 14:49 [PATCH] 82xx: kmalloc failure ignored in ep8248e_mdio_probe() Roel Kluin
2009-09-09 18:46 ` Scott Wood
2009-09-24 18:19 ` Kumar Gala

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).