diff options
author | Li Qiang <liq3ea@163.com> | 2019-01-03 05:12:51 -0800 |
---|---|---|
committer | Marcel Apfelbaum <marcel.apfelbaum@gmail.com> | 2019-01-19 10:57:48 +0200 |
commit | a5fe209d71f311afb0035ce39e9472f9b31445e9 (patch) | |
tree | 0974b7b5373ad6f92c0522e30de422ef931e4ed4 /hw/rdma | |
parent | a1aa88b7dcac2b22d74908f9276d5d145d8e65a0 (diff) |
hw: rdma: fix an off-by-one issue
In rdma_rm_get_backend_gid_index(), the 'sgid_idx' is used
to index the array 'dev_res->port.gid_tbl' which size is
MAX_PORT_GIDS. Current the 'sgid_idx' may be MAX_PORT_GIDS
thus cause an off-by-one issue.
Spotted by Coverity: CID 1398594
Signed-off-by: Li Qiang <liq3ea@163.com>
Message-Id: <20190103131251.49271-1-liq3ea@163.com>
Signed-off-by: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Diffstat (limited to 'hw/rdma')
-rw-r--r-- | hw/rdma/rdma_rm.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/hw/rdma/rdma_rm.c b/hw/rdma/rdma_rm.c index 8bf241e91f..268ff633a4 100644 --- a/hw/rdma/rdma_rm.c +++ b/hw/rdma/rdma_rm.c @@ -579,7 +579,7 @@ int rdma_rm_del_gid(RdmaDeviceResources *dev_res, RdmaBackendDev *backend_dev, int rdma_rm_get_backend_gid_index(RdmaDeviceResources *dev_res, RdmaBackendDev *backend_dev, int sgid_idx) { - if (unlikely(sgid_idx < 0 || sgid_idx > MAX_PORT_GIDS)) { + if (unlikely(sgid_idx < 0 || sgid_idx >= MAX_PORT_GIDS)) { pr_dbg("Got invalid sgid_idx %d\n", sgid_idx); return -EINVAL; } |