diff options
| -rw-r--r-- | net/core/ethtool.c | 13 | 
1 files changed, 11 insertions, 2 deletions
diff --git a/net/core/ethtool.c b/net/core/ethtool.c index fff6314f4c5e..107b122c8969 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c  | |||
| @@ -1693,14 +1693,23 @@ static int ethtool_get_ringparam(struct net_device *dev, void __user *useraddr) | |||
| 1693 | 1693 | ||
| 1694 | static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr) | 1694 | static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr) | 
| 1695 | { | 1695 | { | 
| 1696 | struct ethtool_ringparam ringparam; | 1696 | struct ethtool_ringparam ringparam, max = { .cmd = ETHTOOL_GRINGPARAM }; | 
| 1697 | 1697 | ||
| 1698 | if (!dev->ethtool_ops->set_ringparam) | 1698 | if (!dev->ethtool_ops->set_ringparam || !dev->ethtool_ops->get_ringparam) | 
| 1699 | return -EOPNOTSUPP; | 1699 | return -EOPNOTSUPP; | 
| 1700 | 1700 | ||
| 1701 | if (copy_from_user(&ringparam, useraddr, sizeof(ringparam))) | 1701 | if (copy_from_user(&ringparam, useraddr, sizeof(ringparam))) | 
| 1702 | return -EFAULT; | 1702 | return -EFAULT; | 
| 1703 | 1703 | ||
| 1704 | dev->ethtool_ops->get_ringparam(dev, &max); | ||
| 1705 | |||
| 1706 | /* ensure new ring parameters are within the maximums */ | ||
| 1707 | if (ringparam.rx_pending > max.rx_max_pending || | ||
| 1708 | ringparam.rx_mini_pending > max.rx_mini_max_pending || | ||
| 1709 | ringparam.rx_jumbo_pending > max.rx_jumbo_max_pending || | ||
| 1710 | ringparam.tx_pending > max.tx_max_pending) | ||
| 1711 | return -EINVAL; | ||
| 1712 | |||
| 1704 | return dev->ethtool_ops->set_ringparam(dev, &ringparam); | 1713 | return dev->ethtool_ops->set_ringparam(dev, &ringparam); | 
| 1705 | } | 1714 | } | 
| 1706 | 1715 | ||
