From: Roel Kluin <roel.kluin@gmail.com>
To: benh@kernel.crashing.org, paulus@samba.org,
linuxppc-dev@ozlabs.org,
Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH] 82xx: kmalloc failure ignored in ep8248e_mdio_probe()
Date: Wed, 09 Sep 2009 16:49:57 +0200 [thread overview]
Message-ID: <4AA7C095.7090009@gmail.com> (raw)
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)
next reply other threads:[~2009-09-09 14:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-09 14:49 Roel Kluin [this message]
2009-09-09 18:46 ` [PATCH] 82xx: kmalloc failure ignored in ep8248e_mdio_probe() Scott Wood
2009-09-24 18:19 ` Kumar Gala
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4AA7C095.7090009@gmail.com \
--to=roel.kluin@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=benh@kernel.crashing.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).