ethtool: exit the loop when invalid index occurs
Subsystems (2)
PATCH 1/1 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.
--- net/core/ethtool.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/core/ethtool.c +3 -1
@@ -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; }
From: Jean Sacren <[email protected]>
Date: Sun, 27 Apr 2014 02:20:38 -0600
Quoted 9 lines
The commit
3de0b592394d("ethtool: Support for configurable RSS hash key") introduced a new functionethtool_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 <[email protected]>Cc Venkata Duvvuru <[email protected]>
Applied.