]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
RDMA/ocrdma: Fix off by one in ocrdma_query_gid()
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 16 Feb 2015 10:01:36 +0000 (13:01 +0300)
committerRoland Dreier <roland@purestorage.com>
Wed, 18 Feb 2015 16:31:06 +0000 (08:31 -0800)
The ->sgid_tbl[] array has OCRDMA_MAX_SGID number of elements so this
test is off by one.  ->sgid_tbl is allocated in ocrdma_alloc_resources().

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Selvin Xavier <selvin.xavier@emulex.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c

index 397a3678ecfbd0632106ac9df9594d6d2c665d62..877175563634df79a889ed8a428405258b9df1e4 100644 (file)
@@ -53,7 +53,7 @@ int ocrdma_query_gid(struct ib_device *ibdev, u8 port,
 
        dev = get_ocrdma_dev(ibdev);
        memset(sgid, 0, sizeof(*sgid));
-       if (index > OCRDMA_MAX_SGID)
+       if (index >= OCRDMA_MAX_SGID)
                return -EINVAL;
 
        memcpy(sgid, &dev->sgid_tbl[index], sizeof(*sgid));