[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1479397251-6932-3-git-send-email-tariqt@mellanox.com>
Date: Thu, 17 Nov 2016 17:40:50 +0200
From: Tariq Toukan <tariqt@...lanox.com>
To: "David S. Miller" <davem@...emloft.net>
Cc: netdev@...r.kernel.org, Eran Ben Elisha <eranbe@...lanox.com>,
Saeed Mahameed <saeedm@...lanox.com>,
Eugenia Emantayev <eugenia@...lanox.com>,
Tariq Toukan <tariqt@...lanox.com>,
Jiri Pirko <jiri@...lanox.com>
Subject: [PATCH net 2/3] net: Check netdevice presence on dev_get_phys_port_id
From: Eugenia Emantayev <eugenia@...lanox.com>
Check presence of network device before calling device driver
ndo_get_phys_port_id callback. Otherwise callback may access
non-existing data structures and cause kernel panic.
Fixes: 66b52b0dc82c ("net: add ndo to get id of physical port of the device")
Signed-off-by: Eugenia Emantayev <eugenia@...lanox.com>
Signed-off-by: Tariq Toukan <tariqt@...lanox.com>
Reported-by: Sebastian Ott <sebott@...ux.vnet.ibm.com>
Reported-by: Steve Wise <swise@...ngridcomputing.com>
Cc: Jiri Pirko <jiri@...lanox.com>
---
net/core/dev.c | 2 ++
net/core/rtnetlink.c | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index 6666b28b6815..7de0d000a9f8 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6602,6 +6602,8 @@ int dev_get_phys_port_id(struct net_device *dev,
if (!ops->ndo_get_phys_port_id)
return -EOPNOTSUPP;
+ if (!netif_device_present(dev))
+ return -ENODEV;
return ops->ndo_get_phys_port_id(dev, ppid);
}
EXPORT_SYMBOL(dev_get_phys_port_id);
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index a6529c55ffb7..b3dd81f82e70 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1036,7 +1036,7 @@ static int rtnl_phys_port_id_fill(struct sk_buff *skb, struct net_device *dev)
err = dev_get_phys_port_id(dev, &ppid);
if (err) {
- if (err == -EOPNOTSUPP)
+ if (err == -EOPNOTSUPP || err == -ENODEV)
return 0;
return err;
}
--
1.8.3.1
Powered by blists - more mailing lists