]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ethtool: Return immediately on error in ethtool_copy_validate_indir()
authorBen Hutchings <ben@decadent.org.uk>
Wed, 14 May 2014 23:46:45 +0000 (00:46 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Mon, 19 May 2014 00:17:32 +0000 (01:17 +0100)
We must return -EFAULT immediately rather than continuing into
the loop.

Similarly, we may as well return -EINVAL directly.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
net/core/ethtool.c

index aa8978ac47d28b8588ff78e02e9607b1d616d6d1..c834cb29f68216aa701f3d1c9e7bf764ec22946b 100644 (file)
@@ -561,19 +561,17 @@ static int ethtool_copy_validate_indir(u32 *indir, void __user *useraddr,
                                        struct ethtool_rxnfc *rx_rings,
                                        u32 size)
 {
-       int ret = 0, i;
+       int i;
 
        if (copy_from_user(indir, useraddr, size * sizeof(indir[0])))
-               ret = -EFAULT;
+               return -EFAULT;
 
        /* Validate ring indices */
-       for (i = 0; i < size; i++) {
-               if (indir[i] >= rx_rings->data) {
-                       ret = -EINVAL;
-                       break;
-               }
-       }
-       return ret;
+       for (i = 0; i < size; i++)
+               if (indir[i] >= rx_rings->data)
+                       return -EINVAL;
+
+       return 0;
 }
 
 static noinline_for_stack int ethtool_get_rxfh_indir(struct net_device *dev,