提交 266a1646 编写于 作者: J Jean Sacren 提交者: 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: NJean Sacren <sakiwit@gmail.com>
Cc: Venkata Duvvuru <VenkatKumar.Duvvuru@Emulex.Com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册