hw/rdma: Fix possible out of bounds access to port GID index
authorMarcel Apfelbaum <marcel.apfelbaum@gmail.com>
Mon, 30 Apr 2018 20:02:23 +0000 (23:02 +0300)
committerMarcel Apfelbaum <marcel.apfelbaum@gmail.com>
Thu, 3 May 2018 17:52:29 +0000 (20:52 +0300)
Make sure the backend GID index is less then port's
gid table length.

Signed-off-by: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Reviewed-by: Yuval Shaia <yuval.shaia@oracle.com>
Message-Id: <20180430200223.4119-8-marcel.apfelbaum@gmail.com>

hw/rdma/rdma_backend.c

index 5c7b3d8949242fe3010e2a70a9abcf1674c621ff..e9ced6f9efc1918b27fce8c6227c19ade204ead7 100644 (file)
@@ -774,7 +774,7 @@ int rdma_backend_init(RdmaBackendDev *backend_dev,
         goto out_destroy_comm_channel;
     }
 
-    if (backend_dev->backend_gid_idx > port_attr.gid_tbl_len) {
+    if (backend_dev->backend_gid_idx >= port_attr.gid_tbl_len) {
         error_setg(errp, "Invalid backend_gid_idx, should be less than %d",
                    port_attr.gid_tbl_len);
         goto out_destroy_comm_channel;