From: Dan Carpenter <dan.carpenter@oracle.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: "Gustavo A. R. Silva" <gustavo@embeddedor.com>,
David Woodhouse <dwmw2@infradead.org>,
netdev@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH net] net: atm: clean up a range check
Date: Fri, 03 May 2019 12:39:48 +0000 [thread overview]
Message-ID: <20190503123948.GD29695@mwanda> (raw)
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>
---
This applies to net, but it's just a clean up.
net/atm/lec.c | 4 +---
1 file changed, 1 insertion(+), 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)
struct lec_priv *priv;
if (arg < 0)
- i = 0;
- else
- i = arg;
+ arg = 0;
if (arg >= MAX_LEC_ITF)
return -EINVAL;
i = array_index_nospec(arg, MAX_LEC_ITF);
--
2.18.0
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: "Gustavo A. R. Silva" <gustavo@embeddedor.com>,
David Woodhouse <dwmw2@infradead.org>,
netdev@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH net] net: atm: clean up a range check
Date: Fri, 3 May 2019 15:39:48 +0300 [thread overview]
Message-ID: <20190503123948.GD29695@mwanda> (raw)
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>
---
This applies to net, but it's just a clean up.
net/atm/lec.c | 4 +---
1 file changed, 1 insertion(+), 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)
struct lec_priv *priv;
if (arg < 0)
- i = 0;
- else
- i = arg;
+ arg = 0;
if (arg >= MAX_LEC_ITF)
return -EINVAL;
i = array_index_nospec(arg, MAX_LEC_ITF);
--
2.18.0
next reply other threads:[~2019-05-03 12:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-03 12:39 Dan Carpenter [this message]
2019-05-03 12:39 ` [PATCH net] net: atm: clean up a range check Dan Carpenter
2019-05-05 17:26 ` David Miller
2019-05-05 17:26 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190503123948.GD29695@mwanda \
--to=dan.carpenter@oracle.com \
--cc=davem@davemloft.net \
--cc=dwmw2@infradead.org \
--cc=gustavo@embeddedor.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.