diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2019-05-03 08:39:48 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-05-05 13:25:52 -0400 |
commit | fdd1a8103a6df50bdeacd8bb04c3f6976cb9ae41 (patch) | |
tree | e3cb2e36234846a202687b87f6b29b029bf8ab0d /net/atm | |
parent | 6ffe0acc935f344eb0b35da07c034d5122222e77 (diff) |
net: atm: clean up a range check
The code works fine but the problem is that check for negatives is a
no-op:
if (arg < 0)
i = 0;
The "i" value isn't used. We immediately overwrite it with:
i = array_index_nospec(arg, MAX_LEC_ITF);
The array_index_nospec() macro returns zero if "arg" is out of bounds so
this works, but the dead code is confusing and it doesn't look very
intentional.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/atm')
-rw-r--r-- | net/atm/lec.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/net/atm/lec.c b/net/atm/lec.c index ad4f829193f0..a0311493b01b 100644 --- a/net/atm/lec.c +++ b/net/atm/lec.c | |||
@@ -726,9 +726,7 @@ static int lecd_attach(struct atm_vcc *vcc, int arg) | |||
726 | struct lec_priv *priv; | 726 | struct lec_priv *priv; |
727 | 727 | ||
728 | if (arg < 0) | 728 | if (arg < 0) |
729 | i = 0; | 729 | arg = 0; |
730 | else | ||
731 | i = arg; | ||
732 | if (arg >= MAX_LEC_ITF) | 730 | if (arg >= MAX_LEC_ITF) |
733 | return -EINVAL; | 731 | return -EINVAL; |
734 | i = array_index_nospec(arg, MAX_LEC_ITF); | 732 | i = array_index_nospec(arg, MAX_LEC_ITF); |