qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] hw: rdma: fix an off-by-one issue
@ 2019-01-03 13:12 Li Qiang
  2019-01-07 17:31 ` Marcel Apfelbaum
  0 siblings, 1 reply; 2+ messages in thread
From: Li Qiang @ 2019-01-03 13:12 UTC (permalink / raw)
  To: yuval.shaia, marcel.apfelbaum; +Cc: qemu-devel, peter.maydell, Li Qiang

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>
---
 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;
     }
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] hw: rdma: fix an off-by-one issue
  2019-01-03 13:12 [Qemu-devel] [PATCH] hw: rdma: fix an off-by-one issue Li Qiang
@ 2019-01-07 17:31 ` Marcel Apfelbaum
  0 siblings, 0 replies; 2+ messages in thread
From: Marcel Apfelbaum @ 2019-01-07 17:31 UTC (permalink / raw)
  To: Li Qiang, yuval.shaia; +Cc: qemu-devel, peter.maydell



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 <liq3ea@163.com>
> ---
>   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<marcel.apfelbaum@gmail.com>

Thanks,
Marcel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-01-07 17:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-03 13:12 [Qemu-devel] [PATCH] hw: rdma: fix an off-by-one issue Li Qiang
2019-01-07 17:31 ` Marcel Apfelbaum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).