aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorBen Hutchings <ben@decadent.org.uk>2014-05-14 19:46:45 -0400
committerBen Hutchings <ben@decadent.org.uk>2014-05-18 20:17:32 -0400
commitfb95cd8d1473b1cc90eccbd6a30641f3851c8506 (patch)
treed6e22b245809be974c3a3ac95d33fe24c16c7e09 /net
parenteb02a272c97b6e25d8e5fcf1ea93923e6f155595 (diff)
ethtool: Return immediately on error in ethtool_copy_validate_indir()
We must return -EFAULT immediately rather than continuing into the loop. Similarly, we may as well return -EINVAL directly. Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'net')
-rw-r--r--net/core/ethtool.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index aa8978ac47d2..c834cb29f682 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -561,19 +561,17 @@ static int ethtool_copy_validate_indir(u32 *indir, void __user *useraddr,
561 struct ethtool_rxnfc *rx_rings, 561 struct ethtool_rxnfc *rx_rings,
562 u32 size) 562 u32 size)
563{ 563{
564 int ret = 0, i; 564 int i;
565 565
566 if (copy_from_user(indir, useraddr, size * sizeof(indir[0]))) 566 if (copy_from_user(indir, useraddr, size * sizeof(indir[0])))
567 ret = -EFAULT; 567 return -EFAULT;
568 568
569 /* Validate ring indices */ 569 /* Validate ring indices */
570 for (i = 0; i < size; i++) { 570 for (i = 0; i < size; i++)
571 if (indir[i] >= rx_rings->data) { 571 if (indir[i] >= rx_rings->data)
572 ret = -EINVAL; 572 return -EINVAL;
573 break; 573
574 } 574 return 0;
575 }
576 return ret;
577} 575}
578 576
579static noinline_for_stack int ethtool_get_rxfh_indir(struct net_device *dev, 577static noinline_for_stack int ethtool_get_rxfh_indir(struct net_device *dev,