summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorSergei Shtylyov <sergei.shtylyov@cogentembedded.com>2014-04-19 08:51:43 +0530
committerMarek Szyprowski <m.szyprowski@samsung.com>2014-05-13 05:29:55 -0700
commit3f2fbd1a93a6652b99af3e952aa672ec5fd1ee50 (patch)
treee4d9b0466b3e4a510cc4be02ed3b6439a33ef827 /drivers
parent53330dde8c25c6a1a9fc73222470183ff8240845 (diff)
downloadlinux-3.10-3f2fbd1a93a6652b99af3e952aa672ec5fd1ee50.tar.gz
linux-3.10-3f2fbd1a93a6652b99af3e952aa672ec5fd1ee50.tar.bz2
linux-3.10-3f2fbd1a93a6652b99af3e952aa672ec5fd1ee50.zip
phy: fix kernel oops in phy_lookup()
The kernel oopses in phy_lookup() due to 'phy->init_data' being NULL if we register PHYs from a device tree probing driver and then call phy_get() on a device that has no representation in the device tree (e.g. a PCI device). Checking the pointer before dereferening it and skipping an interation if it's NULL prevents this kernel oops. Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> [backport from upstream commit 743bb387a1edbf1ebbba6cf77c1af3e488886c39] Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Change-Id: Iea16343af63965d19960fc8acf89e0a65b806440
Diffstat (limited to 'drivers')
-rw-r--r--drivers/phy/phy-core.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 623b71c54b3..c64a2f3b2d6 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -64,6 +64,9 @@ static struct phy *phy_lookup(struct device *device, const char *port)
class_dev_iter_init(&iter, phy_class, NULL, NULL);
while ((dev = class_dev_iter_next(&iter))) {
phy = to_phy(dev);
+
+ if (!phy->init_data)
+ continue;
count = phy->init_data->num_consumers;
consumers = phy->init_data->consumers;
while (count--) {