From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: kishon@ti.com
Cc: linux-sh@vger.kernel.org, magnus.damm@gmail.com,
linux-kernel@vger.kernel.org
Subject: [PATCH] phy: fix kernel oops in phy_lookup()
Date: Fri, 11 Apr 2014 02:59:42 +0400 [thread overview]
Message-ID: <201404110259.43282.sergei.shtylyov@cogentembedded.com> (raw)
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>
---
The patch is against the 'fixes' branch of Kishon's 'linux-phy.git' repo.
drivers/phy/phy-core.c | 3 +++
1 file changed, 3 insertions(+)
Index: linux-phy/drivers/phy/phy-core.c
===================================================================
--- linux-phy.orig/drivers/phy/phy-core.c
+++ linux-phy/drivers/phy/phy-core.c
@@ -64,6 +64,9 @@ static struct phy *phy_lookup(struct dev
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--) {
reply other threads:[~2014-04-10 22:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201404110259.43282.sergei.shtylyov@cogentembedded.com \
--to=sergei.shtylyov@cogentembedded.com \
--cc=kishon@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=magnus.damm@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®