lkml.org 
[lkml]   [2015]   [Apr]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH linux-next 4/4] net/dsa: fix possible NULL pointer dereference in dsa_slave_get_iflink
Date
Signed-off-by: Honggang Li <honli@redhat.com>
---
net/dsa/slave.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 827cda56..070b599 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -59,7 +59,10 @@ static int dsa_slave_get_iflink(const struct net_device *dev)
{
struct dsa_slave_priv *p = netdev_priv(dev);

- return p->parent->dst->master_netdev->ifindex;
+ if (p && p->parent && p->parent->dst && p->parent->dst->master_netdev)
+ return p->parent->dst->master_netdev->ifindex;
+ else
+ return 0;
}

static inline bool dsa_port_is_bridged(struct dsa_slave_priv *p)
--
1.8.3.1


\
 
 \ /
  Last update: 2015-04-14 18:01    [W:0.196 / U:1.376 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site