net: sysfs: ethtool_ops can be NULL
commit d519e17e2d
(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>
This commit is contained in:
parent
b75c6dbb45
commit
ac5e3af999
@ -139,7 +139,9 @@ static ssize_t show_speed(struct device *dev,
|
|||||||
if (!rtnl_trylock())
|
if (!rtnl_trylock())
|
||||||
return restart_syscall();
|
return restart_syscall();
|
||||||
|
|
||||||
if (netif_running(netdev) && netdev->ethtool_ops->get_settings) {
|
if (netif_running(netdev) &&
|
||||||
|
netdev->ethtool_ops &&
|
||||||
|
netdev->ethtool_ops->get_settings) {
|
||||||
struct ethtool_cmd cmd = { ETHTOOL_GSET };
|
struct ethtool_cmd cmd = { ETHTOOL_GSET };
|
||||||
|
|
||||||
if (!netdev->ethtool_ops->get_settings(netdev, &cmd))
|
if (!netdev->ethtool_ops->get_settings(netdev, &cmd))
|
||||||
@ -158,7 +160,9 @@ static ssize_t show_duplex(struct device *dev,
|
|||||||
if (!rtnl_trylock())
|
if (!rtnl_trylock())
|
||||||
return restart_syscall();
|
return restart_syscall();
|
||||||
|
|
||||||
if (netif_running(netdev) && netdev->ethtool_ops->get_settings) {
|
if (netif_running(netdev) &&
|
||||||
|
netdev->ethtool_ops &&
|
||||||
|
netdev->ethtool_ops->get_settings) {
|
||||||
struct ethtool_cmd cmd = { ETHTOOL_GSET };
|
struct ethtool_cmd cmd = { ETHTOOL_GSET };
|
||||||
|
|
||||||
if (!netdev->ethtool_ops->get_settings(netdev, &cmd))
|
if (!netdev->ethtool_ops->get_settings(netdev, &cmd))
|
||||||
|
Loading…
Reference in New Issue
Block a user