summaryrefslogtreecommitdiffstats
path: root/net/core/ethtool.c
diff options
context:
space:
mode:
authorJean Sacren <sakiwit@gmail.com>2014-04-27 10:20:38 +0200
committerDavid S. Miller <davem@davemloft.net>2014-04-28 19:28:43 +0200
commit266a16468432a77f2e1395b3de5df3ca699b1a9a (patch)
treea7cc7f9a4b18cb5654d05f9a77b29eb5a3e91c00 /net/core/ethtool.c
parentsched, act: allow to clear all actions as well (diff)
downloadlinux-266a16468432a77f2e1395b3de5df3ca699b1a9a.tar.xz
linux-266a16468432a77f2e1395b3de5df3ca699b1a9a.zip
ethtool: exit the loop when invalid index occurs
The commit 3de0b592394d ("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: Jean Sacren <sakiwit@gmail.com> Cc: Venkata Duvvuru <VenkatKumar.Duvvuru@Emulex.Com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/ethtool.c')
-rw-r--r--net/core/ethtool.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 1d72786ef866..aa8978ac47d2 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -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;
}