devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hovold <jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: "David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
	Florian Fainelli
	<f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Mugunthan V N <mugunthanvnm-l0cyMroinI0@public.gmane.org>,
	Johan Hovold <jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	stable <stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: [PATCH RESEND 4/5] net: cpsw: fix null dereference at probe
Date: Thu,  8 May 2014 10:09:23 +0200	[thread overview]
Message-ID: <1399536564-7626-5-git-send-email-jhovold@gmail.com> (raw)
In-Reply-To: <1399536564-7626-1-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Fix null-pointer dereference at probe when the mdio platform device is
missing (e.g. when it has been disabled in DT).

Cc: stable <stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>	# v3.8
Signed-off-by: Johan Hovold <jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/net/ethernet/ti/cpsw.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 18d83d8d7f74..db9360cd861c 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -1871,6 +1871,10 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
 		mdio_node = of_find_node_by_phandle(be32_to_cpup(parp));
 		phyid = be32_to_cpup(parp+1);
 		mdio = of_find_device_by_node(mdio_node);
+		if (!mdio) {
+			pr_err("Missing mdio platform device\n");
+			return -EINVAL;
+		}
 		snprintf(slave_data->phy_id, sizeof(slave_data->phy_id),
 			 PHY_ID_FMT, mdio->name, phyid);
 
-- 
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2014-05-08  8:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-08  7:37 [PATCH 0/5] net: cpsw and mdio-gpio fixes for v3.15-final Johan Hovold
     [not found] ` <1399534639-4947-1-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-05-08  7:37   ` [PATCH 1/5] net: mdio-gpio: fix device-tree binding documentation Johan Hovold
2014-05-08  7:37 ` [PATCH 2/5] net: mdio-gpio: warn about missing bus alias id Johan Hovold
2014-05-08  7:37 ` [PATCH 5/5] net: cpsw: add missing of_node_put Johan Hovold
2014-05-08  8:09 ` [PATCH RESEND 0/5] net: cpsw and mdio-gpio fixes for v3.15-final Johan Hovold
2014-05-08  8:09   ` [PATCH RESEND 1/5] net: mdio-gpio: fix device-tree binding documentation Johan Hovold
2014-05-08  8:09   ` [PATCH RESEND 2/5] net: mdio-gpio: warn about missing bus alias id Johan Hovold
2014-05-08  8:09   ` [PATCH RESEND 3/5] Revert "net: eth: cpsw: Correctly attach to GPIO bitbang MDIO driver" Johan Hovold
     [not found]   ` <1399536564-7626-1-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-05-08  8:09     ` Johan Hovold [this message]
2014-05-08  8:09   ` [PATCH RESEND 5/5] net: cpsw: add missing of_node_put Johan Hovold
2014-05-09 19:51   ` [PATCH RESEND 0/5] net: cpsw and mdio-gpio fixes for v3.15-final David Miller

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=1399536564-7626-5-git-send-email-jhovold@gmail.com \
    --to=jhovold-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mugunthanvnm-l0cyMroinI0@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /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;
as well as URLs for NNTP newsgroup(s).