Skip to content

Commit a75895b

Browse files
Andrew Boyerdledford
authored andcommitted
RDMA/i40iw: Avoid panic when objects are being created and destroyed
A panic occurs when there is a newly-registered element on the QP/CQ MR list waiting to be attached, but a different MR is deregistered. The current code only checks for whether the list is empty, not whether the element being deregistered is actually on the list. Fix the panic by adding a boolean to track if the object is on the list. Fixes: d374984 ("i40iw: add files for iwarp interface") Signed-off-by: Andrew Boyer <[email protected]> Reviewed-by: Shiraz Saleem <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent a0403be commit a75895b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

drivers/infiniband/hw/i40iw/i40iw_verbs.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ static struct i40iw_pbl *i40iw_get_pbl(unsigned long va,
394394

395395
list_for_each_entry(iwpbl, pbl_list, list) {
396396
if (iwpbl->user_base == va) {
397+
iwpbl->on_list = false;
397398
list_del(&iwpbl->list);
398399
return iwpbl;
399400
}
@@ -1898,6 +1899,7 @@ static struct ib_mr *i40iw_reg_user_mr(struct ib_pd *pd,
18981899
goto error;
18991900
spin_lock_irqsave(&ucontext->qp_reg_mem_list_lock, flags);
19001901
list_add_tail(&iwpbl->list, &ucontext->qp_reg_mem_list);
1902+
iwpbl->on_list = true;
19011903
spin_unlock_irqrestore(&ucontext->qp_reg_mem_list_lock, flags);
19021904
break;
19031905
case IW_MEMREG_TYPE_CQ:
@@ -1908,6 +1910,7 @@ static struct ib_mr *i40iw_reg_user_mr(struct ib_pd *pd,
19081910

19091911
spin_lock_irqsave(&ucontext->cq_reg_mem_list_lock, flags);
19101912
list_add_tail(&iwpbl->list, &ucontext->cq_reg_mem_list);
1913+
iwpbl->on_list = true;
19111914
spin_unlock_irqrestore(&ucontext->cq_reg_mem_list_lock, flags);
19121915
break;
19131916
case IW_MEMREG_TYPE_MEM:
@@ -2045,14 +2048,18 @@ static void i40iw_del_memlist(struct i40iw_mr *iwmr,
20452048
switch (iwmr->type) {
20462049
case IW_MEMREG_TYPE_CQ:
20472050
spin_lock_irqsave(&ucontext->cq_reg_mem_list_lock, flags);
2048-
if (!list_empty(&ucontext->cq_reg_mem_list))
2051+
if (iwpbl->on_list) {
2052+
iwpbl->on_list = false;
20492053
list_del(&iwpbl->list);
2054+
}
20502055
spin_unlock_irqrestore(&ucontext->cq_reg_mem_list_lock, flags);
20512056
break;
20522057
case IW_MEMREG_TYPE_QP:
20532058
spin_lock_irqsave(&ucontext->qp_reg_mem_list_lock, flags);
2054-
if (!list_empty(&ucontext->qp_reg_mem_list))
2059+
if (iwpbl->on_list) {
2060+
iwpbl->on_list = false;
20552061
list_del(&iwpbl->list);
2062+
}
20562063
spin_unlock_irqrestore(&ucontext->qp_reg_mem_list_lock, flags);
20572064
break;
20582065
default:

drivers/infiniband/hw/i40iw/i40iw_verbs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ struct i40iw_pbl {
7878
};
7979

8080
bool pbl_allocated;
81+
bool on_list;
8182
u64 user_base;
8283
struct i40iw_pble_alloc pble_alloc;
8384
struct i40iw_mr *iwmr;

0 commit comments

Comments
 (0)