Commit fb95cd8d authored by Ben Hutchings's avatar Ben Hutchings

ethtool: Return immediately on error in ethtool_copy_validate_indir()

We must return -EFAULT immediately rather than continuing into
the loop.

Similarly, we may as well return -EINVAL directly.
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent eb02a272
...@@ -561,19 +561,17 @@ static int ethtool_copy_validate_indir(u32 *indir, void __user *useraddr, ...@@ -561,19 +561,17 @@ static int ethtool_copy_validate_indir(u32 *indir, void __user *useraddr,
struct ethtool_rxnfc *rx_rings, struct ethtool_rxnfc *rx_rings,
u32 size) u32 size)
{ {
int ret = 0, i; int i;
if (copy_from_user(indir, useraddr, size * sizeof(indir[0]))) if (copy_from_user(indir, useraddr, size * sizeof(indir[0])))
ret = -EFAULT; return -EFAULT;
/* Validate ring indices */ /* Validate ring indices */
for (i = 0; i < size; i++) { for (i = 0; i < size; i++)
if (indir[i] >= rx_rings->data) { if (indir[i] >= rx_rings->data)
ret = -EINVAL; return -EINVAL;
break;
} return 0;
}
return ret;
} }
static noinline_for_stack int ethtool_get_rxfh_indir(struct net_device *dev, static noinline_for_stack int ethtool_get_rxfh_indir(struct net_device *dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment