lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 13 Mar 2012 18:58:22 +0800
From:	Dong Aisheng <b29396@...escale.com>
To:	<netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
	<linux-arm-kernel@...ts.infradead.org>
CC:	<davem@...emloft.net>, <timur@...escale.com>,
	<rdunlap@...otime.net>, <kernel@...gutronix.de>
Subject: [PATCH 1/1] net: phylib: add error checking if no phy found

From: Dong Aisheng <dong.aisheng@...aro.org>

Signed-off-by: Dong Aisheng <dong.aisheng@...aro.org>
---
 drivers/net/phy/mdio_bus.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 88cc5db..d8e044d 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -101,6 +101,7 @@ static struct class mdio_bus_class = {
 int mdiobus_register(struct mii_bus *bus)
 {
 	int i, err;
+	u32 phynum = 0;
 
 	if (NULL == bus || NULL == bus->name ||
 			NULL == bus->read ||
@@ -134,12 +135,20 @@ int mdiobus_register(struct mii_bus *bus)
 			if (IS_ERR(phydev)) {
 				err = PTR_ERR(phydev);
 				goto error;
+			} else if (phydev != NULL) {
+				phynum++;
 			}
 		}
 	}
 
+	if (!phynum) {
+		err = -ENODEV;
+		printk(KERN_ERR "%s: no phys found\n", bus->name);
+		goto error;
+	}
+
 	bus->state = MDIOBUS_REGISTERED;
-	pr_info("%s: probed\n", bus->name);
+	pr_info("%s: %d phys probed\n", bus->name, phynum);
 	return 0;
 
 error:
-- 
1.7.0.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ