aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/phy
diff options
context:
space:
mode:
authorSergei Shtylyov <sergei.shtylyov@cogentembedded.com>2014-04-18 23:21:43 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-04-24 15:53:38 -0400
commit743bb387a1edbf1ebbba6cf77c1af3e488886c39 (patch)
treeaf51f66f28ac16b87bd8d4dbe344cfeec4d7905a /drivers/phy
parent907aa3aa8dbb5437696776d40caeea245c8ba3bd (diff)
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>
Diffstat (limited to 'drivers/phy')
-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 623b71c54b3e..c64a2f3b2d62 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)
64 class_dev_iter_init(&iter, phy_class, NULL, NULL); 64 class_dev_iter_init(&iter, phy_class, NULL, NULL);
65 while ((dev = class_dev_iter_next(&iter))) { 65 while ((dev = class_dev_iter_next(&iter))) {
66 phy = to_phy(dev); 66 phy = to_phy(dev);
67
68 if (!phy->init_data)
69 continue;
67 count = phy->init_data->num_consumers; 70 count = phy->init_data->num_consumers;
68 consumers = phy->init_data->consumers; 71 consumers = phy->init_data->consumers;
69 while (count--) { 72 while (count--) {