aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2009-10-25 21:23:33 -0400
committerDavid S. Miller <davem@davemloft.net>2009-10-28 06:59:46 -0400
commitac5e3af9996fb911d4fdff910a8ac3cb7fc63a94 (patch)
treec6c56403289c8bff16884592dc76d276444e9f04 /net/core
parentb75c6dbb45a49289b90f885c7fb6d9ac39a21688 (diff)
net: sysfs: ethtool_ops can be NULL
commit d519e17e2d01a0ee9abe083019532061b4438065 (net: export device speed and duplex via sysfs) made the wrong assumption that netdev->ethtool_ops was always set. This makes possible to crash kernel and let rtnl in locked state. modprobe dummy ip link set dummy0 up (udev runs and crash) Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Acked-by: Andy Gospodarek <andy@greyhouse.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/net-sysfs.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 753c420060df..89de182353b0 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -139,7 +139,9 @@ static ssize_t show_speed(struct device *dev,
139 if (!rtnl_trylock()) 139 if (!rtnl_trylock())
140 return restart_syscall(); 140 return restart_syscall();
141 141
142 if (netif_running(netdev) && netdev->ethtool_ops->get_settings) { 142 if (netif_running(netdev) &&
143 netdev->ethtool_ops &&
144 netdev->ethtool_ops->get_settings) {
143 struct ethtool_cmd cmd = { ETHTOOL_GSET }; 145 struct ethtool_cmd cmd = { ETHTOOL_GSET };
144 146
145 if (!netdev->ethtool_ops->get_settings(netdev, &cmd)) 147 if (!netdev->ethtool_ops->get_settings(netdev, &cmd))
@@ -158,7 +160,9 @@ static ssize_t show_duplex(struct device *dev,
158 if (!rtnl_trylock()) 160 if (!rtnl_trylock())
159 return restart_syscall(); 161 return restart_syscall();
160 162
161 if (netif_running(netdev) && netdev->ethtool_ops->get_settings) { 163 if (netif_running(netdev) &&
164 netdev->ethtool_ops &&
165 netdev->ethtool_ops->get_settings) {
162 struct ethtool_cmd cmd = { ETHTOOL_GSET }; 166 struct ethtool_cmd cmd = { ETHTOOL_GSET };
163 167
164 if (!netdev->ethtool_ops->get_settings(netdev, &cmd)) 168 if (!netdev->ethtool_ops->get_settings(netdev, &cmd))