diff options
author | Clément Leger <cleger@kalray.eu> | 2017-09-05 10:56:24 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2017-09-06 14:45:52 +0200 |
commit | 57c9a40d8e3a437dbbaa8e463008eaf22214e5c8 (patch) | |
tree | f450f5d66bd6384f88398b00a4cda4c1f76a3c57 /drivers/net/phy | |
parent | c4531782266fafe767cd913baecc8c5d270fac76 (diff) | |
download | barebox-57c9a40d8e3a437dbbaa8e463008eaf22214e5c8.tar.gz barebox-57c9a40d8e3a437dbbaa8e463008eaf22214e5c8.tar.xz |
Phy: Check NULL bus case and undetected phy via of
From 5e87dc2c24051c2cd2985e513c5a825d51d9bb00 Mon Sep 17 00:00:00 2001
From: Clement Leger <clement.leger@kalray.eu>
Date: Tue, 5 Sep 2017 10:37:23 +0200
Subject: [PATCH] Phy: Check NULL bus case and undetected phy via of
phy_device_connect can be called with NULL miibus for automatic match
with the phy described in the device tree. In the case where the phy
was not detected for some unknown reason, the next calls will be done
with a NULL bus. This will lead to undefined behavior and more probably
crashes.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/net/phy')
-rw-r--r-- | drivers/net/phy/phy.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 25ae40233e..35a9ce7ea8 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -405,6 +405,11 @@ int phy_device_connect(struct eth_device *edev, struct mii_bus *bus, int addr, goto out; } + if (!bus) { + ret = -ENODEV; + goto out; + } + if (addr >= 0) { phy = mdiobus_scan(bus, addr); if (IS_ERR(phy)) { |