[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1438121533-21528-3-git-send-email-mohun106@gmail.com>
Date: Tue, 28 Jul 2015 15:12:12 -0700
From: mohun106@...il.com
To: f.fainelli@...il.com, netdev@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Cc: ddaney@...iumnetworks.com, sgoutham@...iumnetworks.com,
Radha Mohan Chintakuntla <rchintakuntla@...ium.com>,
Tomasz Nowicki <tomasz.nowicki@...aro.org>
Subject: [PATCH v2 2/3] net: mdio-octeon: Fix octeon_mdiobus_probe function for return values
From: Radha Mohan Chintakuntla <rchintakuntla@...ium.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@...ium.com>
Signed-off-by: Tomasz Nowicki <tomasz.nowicki@...aro.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 1509937..fcf4e4d 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
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists