qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] hw: rdma: fix an off-by-one issue


From: Marcel Apfelbaum
Subject: Re: [Qemu-devel] [PATCH] hw: rdma: fix an off-by-one issue
Date: Mon, 7 Jan 2019 19:31:06 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1



On 1/3/19 3:12 PM, Li Qiang wrote:
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 <address@hidden>
---
  hw/rdma/rdma_rm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/rdma/rdma_rm.c b/hw/rdma/rdma_rm.c
index f5b1295890..1bbc5f128f 100644
--- a/hw/rdma/rdma_rm.c
+++ b/hw/rdma/rdma_rm.c
@@ -576,7 +576,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;
      }

Reviewed-by: Marcel Apfelbaum<address@hidden>

Thanks,
Marcel






reply via email to

[Prev in Thread] Current Thread [Next in Thread]