ethtool: propagate get_coalesce return value
get_coalesce returns 0 or ERRNO, but the return value isn't checked. The returned coalesce data may be invalid if an ERRNO is set, therefore better check and propagate the return value. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: hongrongxuan <hongrongxuan@huawei.com>
This commit is contained in:
parent
6d524b1d96
commit
cf7cbebb2b
|
@ -1472,11 +1472,14 @@ static noinline_for_stack int ethtool_get_coalesce(struct net_device *dev,
|
|||
void __user *useraddr)
|
||||
{
|
||||
struct ethtool_coalesce coalesce = { .cmd = ETHTOOL_GCOALESCE };
|
||||
int ret;
|
||||
|
||||
if (!dev->ethtool_ops->get_coalesce)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
dev->ethtool_ops->get_coalesce(dev, &coalesce);
|
||||
ret = dev->ethtool_ops->get_coalesce(dev, &coalesce);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (copy_to_user(useraddr, &coalesce, sizeof(coalesce)))
|
||||
return -EFAULT;
|
||||
|
|
Loading…
Reference in New Issue