netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] ethtool: exit the loop when invalid index occurs
@ 2014-04-27  8:20 Jean Sacren
  2014-04-28 17:29 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Jean Sacren @ 2014-04-27  8:20 UTC (permalink / raw)
  To: netdev; +Cc: Venkata Duvvuru

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>
---
 net/core/ethtool.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

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;
 }

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] ethtool: exit the loop when invalid index occurs
  2014-04-27  8:20 [PATCH net-next] ethtool: exit the loop when invalid index occurs Jean Sacren
@ 2014-04-28 17:29 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2014-04-28 17:29 UTC (permalink / raw)
  To: sakiwit; +Cc: netdev, VenkatKumar.Duvvuru

From: Jean Sacren <sakiwit@gmail.com>
Date: Sun, 27 Apr 2014 02:20:38 -0600

> 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>

Applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-04-28 19:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-27  8:20 [PATCH net-next] ethtool: exit the loop when invalid index occurs Jean Sacren
2014-04-28 17:29 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).