diff mbox series

[rdma-next,3/3] RDMA/qedr: Fix out of bounds index check in query pkey

Message ID 1546874876-24589-3-git-send-email-galpress@amazon.com (mailing list archive)
State Mainlined
Commit dbe30dae487e1a232158c24b432d45281c2805b7
Delegated to: Jason Gunthorpe
Headers show
Series [rdma-next,1/3] IB/usnic: Fix out of bounds index check in query pkey | expand

Commit Message

Gal Pressman Jan. 7, 2019, 3:27 p.m. UTC
The pkey table size is QEDR_ROCE_PKEY_TABLE_LEN, index should be tested
for >= QEDR_ROCE_PKEY_TABLE_LEN instead of > QEDR_ROCE_PKEY_TABLE_LEN.

Fixes: a7efd7773e31 ("qedr: Add support for PD,PKEY and CQ verbs")
Cc: Michal Kalderon <Michal.Kalderon@cavium.com>
Cc: Ariel Elior <Ariel.Elior@cavium.com>
Signed-off-by: Gal Pressman <galpress@amazon.com>
---
 drivers/infiniband/hw/qedr/verbs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michal Kalderon Jan. 8, 2019, 10:19 a.m. UTC | #1
> From: Gal Pressman <galpress@amazon.com>
> Sent: Monday, January 07, 2019 5:28 PM
> 
> The pkey table size is QEDR_ROCE_PKEY_TABLE_LEN, index should be tested
> for >= QEDR_ROCE_PKEY_TABLE_LEN instead of >
> QEDR_ROCE_PKEY_TABLE_LEN.
> 
> Fixes: a7efd7773e31 ("qedr: Add support for PD,PKEY and CQ verbs")
> Cc: Michal Kalderon <Michal.Kalderon@cavium.com>
> Cc: Ariel Elior <Ariel.Elior@cavium.com>
> Signed-off-by: Gal Pressman <galpress@amazon.com>
> ---
>  drivers/infiniband/hw/qedr/verbs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/qedr/verbs.c
> b/drivers/infiniband/hw/qedr/verbs.c
> index b342a70e2814..bf37673a8302 100644
> --- a/drivers/infiniband/hw/qedr/verbs.c
> +++ b/drivers/infiniband/hw/qedr/verbs.c
> @@ -67,7 +67,7 @@ static inline int qedr_ib_copy_to_udata(struct ib_udata
> *udata, void *src,
> 
>  int qedr_query_pkey(struct ib_device *ibdev, u8 port, u16 index, u16
> *pkey)  {
> -       if (index > QEDR_ROCE_PKEY_TABLE_LEN)
> +       if (index >= QEDR_ROCE_PKEY_TABLE_LEN)
>                 return -EINVAL;
> 
>         *pkey = QEDR_ROCE_PKEY_DEFAULT;
> --
> 2.7.4

Thanks, 

Acked-by: Michal Kalderon <michal.kalderon@marvell.com>
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c
index b342a70e2814..bf37673a8302 100644
--- a/drivers/infiniband/hw/qedr/verbs.c
+++ b/drivers/infiniband/hw/qedr/verbs.c
@@ -67,7 +67,7 @@  static inline int qedr_ib_copy_to_udata(struct ib_udata *udata, void *src,
 
 int qedr_query_pkey(struct ib_device *ibdev, u8 port, u16 index, u16 *pkey)
 {
-	if (index > QEDR_ROCE_PKEY_TABLE_LEN)
+	if (index >= QEDR_ROCE_PKEY_TABLE_LEN)
 		return -EINVAL;
 
 	*pkey = QEDR_ROCE_PKEY_DEFAULT;