Skip to contentSkip to conversation

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

PATCH Superseded Dan Carpenter 3 participants 5 messages Apr 6, 2020 – Apr 14, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

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()")

---
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(-)
drivers/infiniband/core/cm.c +1 -1
index 4794113ecd59..f7ac5974176f 100644
@@ -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;
 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 9 lines · Dan Carpenter

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()")

---
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

#2 lore raw

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

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 ae78ff3a0f0c ("RDMA/cm: Convert local_id_table to XArray")

---
v2: Use the correct Fixes tag and add Matthew to the CC list.

 drivers/infiniband/core/cm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/cm.c +1 -1
index 4794113ecd59..f7ac5974176f 100644
@@ -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;
 
Signature · 1 line
2.25.1
#4 lore raw
In reply to Dan Carpenter
Quoted 4 lines · Dan Carpenter

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.

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

---
v2: Use the correct Fixes tag and add Matthew to the CC list.

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

Applied to for-next, thanks

Jason