diff options
author | Roel Kluin <roel.kluin@gmail.com> | 2009-09-09 16:49:57 +0200 |
---|---|---|
committer | Kumar Gala <galak@kernel.crashing.org> | 2009-11-05 07:18:00 -0600 |
commit | 58459a4e19e107d793a58a46780def2cea12a391 (patch) | |
tree | b4bb42dd78b291debf72a2c3f8780d700e80915c /arch | |
parent | cb5485a0b99b232c5c7c4c21e2346f8ab7ef555d (diff) | |
download | op-kernel-dev-58459a4e19e107d793a58a46780def2cea12a391.zip op-kernel-dev-58459a4e19e107d793a58a46780def2cea12a391.tar.gz |
powerpc/82xx: kmalloc failure ignored in ep8248e_mdio_probe()
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>
Acked-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/platforms/82xx/ep8248e.c | 15 |
1 files changed, 14 insertions, 1 deletions
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) |