Commit 266a1646 authored by Jean Sacren's avatar Jean Sacren Committed by David S. Miller

ethtool: exit the loop when invalid index occurs

The commit 3de0b592 ("ethtool: Support for configurable RSS hash
key") introduced a new function ethtool_copy_validate_indir() with
full iteration of the loop to validate the ring indices, which could
be an overkill. To minimize the impact, we ought to exit the loop as
soon as the invalid index occurs for the very first time. The
remaining loop simply doesn't serve any more purpose.
Signed-off-by: default avatarJean Sacren <sakiwit@gmail.com>
Cc: Venkata Duvvuru <VenkatKumar.Duvvuru@Emulex.Com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a49eb42a
......@@ -568,8 +568,10 @@ static int ethtool_copy_validate_indir(u32 *indir, void __user *useraddr,
/* Validate ring indices */
for (i = 0; i < size; i++) {
if (indir[i] >= rx_rings->data)
if (indir[i] >= rx_rings->data) {
ret = -EINVAL;
break;
}
}
return ret;
}
......
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