Patchwork [precise,sru,4/5] veth: fix a NULL deref in netif_carrier_off

login
register
mail settings
Submitter Chris J Arges
Date March 25, 2014, 9:03 p.m.
Message ID <1395781387-10928-5-git-send-email-chris.j.arges@canonical.com>
Download mbox | patch
Permalink /patch/333715/
State New
Headers show

Comments

Chris J Arges - March 25, 2014, 9:03 p.m.
From: Eric Dumazet <edumazet@google.com>

BugLink: http://bugs.launchpad.net/bugs/1201869

In commit d0e2c55e7c94 (veth: avoid a NULL deref in veth_stats_one)
we now clear the peer pointers in veth_dellink()

veth_close() must therefore make sure the peer pointer is set.

Reported-by: Tom Parkin <tom.parkin@gmail.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 2efd32ee1b60b0b31404ca47c1ce70e5a5d24ebc)

Signed-off-by: Chris J Arges <chris.j.arges@canonical.com>
---
 drivers/net/veth.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch

diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index f41b98c..e093646 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -207,9 +207,11 @@  static int veth_open(struct net_device *dev)
 static int veth_close(struct net_device *dev)
 {
 	struct veth_priv *priv = netdev_priv(dev);
+	struct net_device *peer = rtnl_dereference(priv->peer);
 
 	netif_carrier_off(dev);
-	netif_carrier_off(rtnl_dereference(priv->peer));
+	if (peer)
+		netif_carrier_off(peer);
 
 	return 0;
 }