diff mbox series

RDMA/cm: Fix an error check in cm_alloc_id_priv()

Message ID 20200406144335.GD68494@mwanda (mailing list archive)
State Superseded
Headers show
Series RDMA/cm: Fix an error check in cm_alloc_id_priv() | expand

Commit Message

Dan Carpenter April 6, 2020, 2:43 p.m. UTC
The xa_alloc_cyclic_irq() function returns either 0 or 1 on success and
negatives on error.  This code treats 1 as an error and returns
ERR_PTR(1) which will cause an Oops in the caller.

Fixes: e8dc4e885c45 ("RDMA/cm: Fix ordering of xa_alloc_cyclic() in ib_create_cm_id()")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
The Fixes tag may not be correct.  That's the patch which introduces an
Oops but we may want to backport this further back.

 drivers/infiniband/core/cm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jason Gunthorpe April 6, 2020, 2:51 p.m. UTC | #1
On Mon, Apr 06, 2020 at 05:43:35PM +0300, Dan Carpenter wrote:
> The xa_alloc_cyclic_irq() function returns either 0 or 1 on success and
> negatives on error.  This code treats 1 as an error and returns
> ERR_PTR(1) which will cause an Oops in the caller.
> 
> Fixes: e8dc4e885c45 ("RDMA/cm: Fix ordering of xa_alloc_cyclic() in ib_create_cm_id()")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> The Fixes tag may not be correct.  That's the patch which introduces an
> Oops but we may want to backport this further back.

Right it should be

Fixes: ae78ff3a0f0c ("RDMA/cm: Convert local_id_table to XArray")

Thanks,
Jason
diff mbox series

Patch

diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index 4794113ecd59..f7ac5974176f 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -862,7 +862,7 @@  static struct cm_id_private *cm_alloc_id_priv(struct ib_device *device,
 
 	ret = xa_alloc_cyclic_irq(&cm.local_id_table, &id, NULL, xa_limit_32b,
 				  &cm.local_id_next, GFP_KERNEL);
-	if (ret)
+	if (ret < 0)
 		goto error;
 	cm_id_priv->id.local_id = (__force __be32)id ^ cm.random_id_operand;