netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: David Miller <davem@davemloft.net>
Cc: netdev <netdev@vger.kernel.org>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Vivien Didelot <vivien.didelot@savoirfairelinux.com>,
	Andrew Lunn <andrew@lunn.ch>
Subject: [PATCH net-next 2/5] dsa: slave: Don't reference NULL pointer during phy_disconnect
Date: Sat, 12 Mar 2016 00:01:37 +0100	[thread overview]
Message-ID: <1457737300-23660-3-git-send-email-andrew@lunn.ch> (raw)
In-Reply-To: <1457737300-23660-1-git-send-email-andrew@lunn.ch>

When the phy is disconnected, the parent pointer to the netdev it was
attached to is set to NULL. The code then tries to suspend the phy,
but dsa_slave_fixed_link_update needs the parent pointer to determine
which switch the phy is connected to. So it dereferenced a NULL
pointer. Check for this condition.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 net/dsa/slave.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 27bf03d11670..49056d90b179 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -896,11 +896,15 @@ static void dsa_slave_adjust_link(struct net_device *dev)
 static int dsa_slave_fixed_link_update(struct net_device *dev,
 				       struct fixed_phy_status *status)
 {
-	struct dsa_slave_priv *p = netdev_priv(dev);
-	struct dsa_switch *ds = p->parent;
+	struct dsa_slave_priv *p;
+	struct dsa_switch *ds;
 
-	if (ds->drv->fixed_link_update)
-		ds->drv->fixed_link_update(ds, p->port, status);
+	if (dev) {
+		p = netdev_priv(dev);
+		ds = p->parent;
+		if (ds->drv->fixed_link_update)
+			ds->drv->fixed_link_update(ds, p->port, status);
+	}
 
 	return 0;
 }
-- 
2.7.0

  parent reply	other threads:[~2016-03-11 23:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-11 23:01 [PATCH net-next 0/5] DSA cleanup and fixes Andrew Lunn
2016-03-11 23:01 ` [PATCH net-next 1/5] dsa: Rename mv88e6123_61_65 to mv88e6123 to be consistent Andrew Lunn
2016-03-13  7:10   ` Vivien Didelot
2016-03-13 15:51     ` Andrew Lunn
2016-03-13 18:48       ` Vivien Didelot
2016-03-11 23:01 ` Andrew Lunn [this message]
2016-03-11 23:01 ` [PATCH net-next 3/5] dsa: Destroy fixed link phys after the phy has been disconnected Andrew Lunn
2016-03-11 23:01 ` [PATCH net-next 4/5] dsa: dsa: Fix freeing of fixed-phys from user ports Andrew Lunn
2016-03-11 23:01 ` [PATCH net-next 5/5] phy: fixed: Fix removal of phys Andrew Lunn
2016-03-11 23:18   ` Florian Fainelli
2016-03-12 17:24     ` Andrew Lunn
2016-03-14 19:44 ` [PATCH net-next 0/5] DSA cleanup and fixes 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=1457737300-23660-3-git-send-email-andrew@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@savoirfairelinux.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;
as well as URLs for NNTP newsgroup(s).