]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ethtool: propagate get_coalesce return value
authorHeiner Kallweit <hkallweit1@gmail.com>
Sat, 23 May 2020 15:40:25 +0000 (17:40 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sat, 23 May 2020 23:57:00 +0000 (16:57 -0700)
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>
net/ethtool/ioctl.c

index 31e0b4e88a9d9fde48230542490b47b253ea7e98..b5df90c981c263a12597bc93f7b2b9a811649368 100644 (file)
@@ -1510,11 +1510,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;