From: mohun106@gmail.com
To: f.fainelli@gmail.com, netdev@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Cc: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>,
Tomasz Nowicki <tomasz.nowicki@linaro.org>
Subject: [PATCH 2/3] net: mdio-octeon: Fix octeon_mdiobus_probe function for return values
Date: Mon, 27 Jul 2015 19:14:42 -0700 [thread overview]
Message-ID: <1438049683-10630-3-git-send-email-mohun106@gmail.com> (raw)
In-Reply-To: <1438049683-10630-1-git-send-email-mohun106@gmail.com>
From: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>
This patch fixes a possible crash in the octeon_mdiobus_probe function
if the return values are not handled properly.
Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>
Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
---
drivers/net/phy/mdio-octeon.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/net/phy/mdio-octeon.c b/drivers/net/phy/mdio-octeon.c
index 507aade..428ae75 100644
--- a/drivers/net/phy/mdio-octeon.c
+++ b/drivers/net/phy/mdio-octeon.c
@@ -277,24 +277,28 @@ static int octeon_mdiobus_probe(struct platform_device *pdev)
return -ENOMEM;
res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-
if (res_mem == NULL) {
dev_err(&pdev->dev, "found no memory resource\n");
- err = -ENXIO;
- goto fail;
+ return -ENXIO;
}
+
bus->mdio_phys = res_mem->start;
bus->regsize = resource_size(res_mem);
+
if (!devm_request_mem_region(&pdev->dev, bus->mdio_phys, bus->regsize,
res_mem->name)) {
dev_err(&pdev->dev, "request_mem_region failed\n");
- goto fail;
+ return -ENXIO;
}
+
bus->register_base =
(u64)devm_ioremap(&pdev->dev, bus->mdio_phys, bus->regsize);
+ if (!bus->register_base) {
+ dev_err(&pdev->dev, "dev_ioremap failed\n");
+ return -ENOMEM;
+ }
bus->mii_bus = mdiobus_alloc();
-
if (!bus->mii_bus)
goto fail;
--
1.7.1
next prev parent reply other threads:[~2015-07-28 2:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-28 2:14 [PATCH 0/3] Add MDIO support to ThunderX NIC driver mohun106
2015-07-28 2:14 ` [PATCH 1/3] net: mdio-octeon: Modify driver to work on both ThunderX and Octeon mohun106
2015-07-28 14:07 ` David Daney
2015-07-28 21:48 ` Radha Mohan
2015-07-28 2:14 ` mohun106 [this message]
2015-07-28 2:14 ` [PATCH 3/3] net: thunderx: Select CONFIG_MDIO_OCTEON for ThunderX NIC mohun106
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=1438049683-10630-3-git-send-email-mohun106@gmail.com \
--to=mohun106@gmail.com \
--cc=f.fainelli@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=rchintakuntla@cavium.com \
--cc=tomasz.nowicki@linaro.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).