mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
vlan/macvlan: fix NULL pointer dereferences in ethtool handlers
Check whether the underlying device provides a set of ethtool ops before checking for individual handlers to avoid NULL pointer dereferences. Reported-by: Art van Breemen <[email protected]> Signed-off-by: Patrick McHardy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
parent
75a241f959
commit
7816a0a862
2 changed files with 8 additions and 4 deletions
|
|
@ -376,7 +376,8 @@ static u32 macvlan_ethtool_get_rx_csum(struct net_device *dev)
|
|||
const struct macvlan_dev *vlan = netdev_priv(dev);
|
||||
struct net_device *lowerdev = vlan->lowerdev;
|
||||
|
||||
if (lowerdev->ethtool_ops->get_rx_csum == NULL)
|
||||
if (lowerdev->ethtool_ops == NULL ||
|
||||
lowerdev->ethtool_ops->get_rx_csum == NULL)
|
||||
return 0;
|
||||
return lowerdev->ethtool_ops->get_rx_csum(lowerdev);
|
||||
}
|
||||
|
|
@ -387,7 +388,8 @@ static int macvlan_ethtool_get_settings(struct net_device *dev,
|
|||
const struct macvlan_dev *vlan = netdev_priv(dev);
|
||||
struct net_device *lowerdev = vlan->lowerdev;
|
||||
|
||||
if (!lowerdev->ethtool_ops->get_settings)
|
||||
if (!lowerdev->ethtool_ops ||
|
||||
!lowerdev->ethtool_ops->get_settings)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
return lowerdev->ethtool_ops->get_settings(lowerdev, cmd);
|
||||
|
|
@ -398,7 +400,8 @@ static u32 macvlan_ethtool_get_flags(struct net_device *dev)
|
|||
const struct macvlan_dev *vlan = netdev_priv(dev);
|
||||
struct net_device *lowerdev = vlan->lowerdev;
|
||||
|
||||
if (!lowerdev->ethtool_ops->get_flags)
|
||||
if (!lowerdev->ethtool_ops ||
|
||||
!lowerdev->ethtool_ops->get_flags)
|
||||
return 0;
|
||||
return lowerdev->ethtool_ops->get_flags(lowerdev);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue