diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2018-05-17 15:33:36 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-05-17 16:27:39 -0400 |
commit | 990a9d4975c974b05a8abaaeca5bbcfc55d31dcb (patch) | |
tree | 3e48d9e97348059ec69c00a807df5a3451c4b3ae /net/ncsi | |
parent | be7f3e59997b7744e8be153b76fca28ac5b71354 (diff) | |
download | linux-990a9d4975c974b05a8abaaeca5bbcfc55d31dcb.tar.gz linux-990a9d4975c974b05a8abaaeca5bbcfc55d31dcb.tar.bz2 linux-990a9d4975c974b05a8abaaeca5bbcfc55d31dcb.zip |
net/ncsi: prevent a couple array underflows
We recently refactored this code and introduced a static checker
warning. Smatch complains that if cmd->index is zero then we would
underflow the arrays. That's obviously true.
The question is whether we prevent cmd->index from being zero at a
different level. I've looked at the code and I don't immediately see
a check for that.
Fixes: 062b3e1b6d4f ("net/ncsi: Refactor MAC, VLAN filters")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ncsi')
-rw-r--r-- | net/ncsi/ncsi-rsp.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/net/ncsi/ncsi-rsp.c b/net/ncsi/ncsi-rsp.c index ce9497966ebe..a6b7c7d5c829 100644 --- a/net/ncsi/ncsi-rsp.c +++ b/net/ncsi/ncsi-rsp.c @@ -347,7 +347,7 @@ static int ncsi_rsp_handler_svf(struct ncsi_request *nr) cmd = (struct ncsi_cmd_svf_pkt *)skb_network_header(nr->cmd); ncf = &nc->vlan_filter; - if (cmd->index > ncf->n_vids) + if (cmd->index == 0 || cmd->index > ncf->n_vids) return -ERANGE; /* Add or remove the VLAN filter. Remember HW indexes from 1 */ @@ -445,7 +445,8 @@ static int ncsi_rsp_handler_sma(struct ncsi_request *nr) ncf = &nc->mac_filter; bitmap = &ncf->bitmap; - if (cmd->index > ncf->n_uc + ncf->n_mc + ncf->n_mixed) + if (cmd->index == 0 || + cmd->index > ncf->n_uc + ncf->n_mc + ncf->n_mixed) return -ERANGE; index = (cmd->index - 1) * ETH_ALEN; |