aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms/82xx
diff options
context:
space:
mode:
authorRoel Kluin <roel.kluin@gmail.com>2009-09-09 10:49:57 -0400
committerKumar Gala <galak@kernel.crashing.org>2009-11-05 08:18:00 -0500
commit58459a4e19e107d793a58a46780def2cea12a391 (patch)
treeb4bb42dd78b291debf72a2c3f8780d700e80915c /arch/powerpc/platforms/82xx
parentcb5485a0b99b232c5c7c4c21e2346f8ab7ef555d (diff)
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/powerpc/platforms/82xx')
-rw-r--r--arch/powerpc/platforms/82xx/ep8248e.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/arch/powerpc/platforms/82xx/ep8248e.c b/arch/powerpc/platforms/82xx/ep8248e.c
index 51fcae41f08a..f9aee182e6f7 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,
132 return -ENOMEM; 132 return -ENOMEM;
133 133
134 bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL); 134 bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
135 if (bus->irq == NULL) {
136 ret = -ENOMEM;
137 goto err_free_bus;
138 }
135 139
136 bus->name = "ep8248e-mdio-bitbang"; 140 bus->name = "ep8248e-mdio-bitbang";
137 bus->parent = &ofdev->dev; 141 bus->parent = &ofdev->dev;
138 snprintf(bus->id, MII_BUS_ID_SIZE, "%x", res.start); 142 snprintf(bus->id, MII_BUS_ID_SIZE, "%x", res.start);
139 143
140 return of_mdiobus_register(bus, ofdev->node); 144 ret = of_mdiobus_register(bus, ofdev->node);
145 if (ret)
146 goto err_free_irq;
147
148 return 0;
149err_free_irq:
150 kfree(bus->irq);
151err_free_bus:
152 free_mdio_bitbang(bus);
153 return ret;
141} 154}
142 155
143static int ep8248e_mdio_remove(struct of_device *ofdev) 156static int ep8248e_mdio_remove(struct of_device *ofdev)