Skip to content

Commit 3711023

Browse files
smalin1davem330
authored andcommitted
qed: qed ll2 race condition fixes
Avoiding qed ll2 race condition and NULL pointer dereference as part of the remove and recovery flows. Changes form V1: - Change (!p_rx->set_prod_addr). - qed_ll2.c checkpatch fixes. Change from V2: - Revert "qed_ll2.c checkpatch fixes". Signed-off-by: Ariel Elior <[email protected]> Signed-off-by: Shai Malin <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7387a72 commit 3711023

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

drivers/net/ethernet/qlogic/qed/qed_ll2.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,9 @@ static int qed_ll2_txq_completion(struct qed_hwfn *p_hwfn, void *p_cookie)
327327
unsigned long flags;
328328
int rc = -EINVAL;
329329

330+
if (!p_ll2_conn)
331+
return rc;
332+
330333
spin_lock_irqsave(&p_tx->lock, flags);
331334
if (p_tx->b_completing_packet) {
332335
rc = -EBUSY;
@@ -500,7 +503,16 @@ static int qed_ll2_rxq_completion(struct qed_hwfn *p_hwfn, void *cookie)
500503
unsigned long flags = 0;
501504
int rc = 0;
502505

506+
if (!p_ll2_conn)
507+
return rc;
508+
503509
spin_lock_irqsave(&p_rx->lock, flags);
510+
511+
if (!QED_LL2_RX_REGISTERED(p_ll2_conn)) {
512+
spin_unlock_irqrestore(&p_rx->lock, flags);
513+
return 0;
514+
}
515+
504516
cq_new_idx = le16_to_cpu(*p_rx->p_fw_cons);
505517
cq_old_idx = qed_chain_get_cons_idx(&p_rx->rcq_chain);
506518

@@ -821,6 +833,9 @@ static int qed_ll2_lb_rxq_completion(struct qed_hwfn *p_hwfn, void *p_cookie)
821833
struct qed_ll2_info *p_ll2_conn = (struct qed_ll2_info *)p_cookie;
822834
int rc;
823835

836+
if (!p_ll2_conn)
837+
return 0;
838+
824839
if (!QED_LL2_RX_REGISTERED(p_ll2_conn))
825840
return 0;
826841

@@ -844,6 +859,9 @@ static int qed_ll2_lb_txq_completion(struct qed_hwfn *p_hwfn, void *p_cookie)
844859
u16 new_idx = 0, num_bds = 0;
845860
int rc;
846861

862+
if (!p_ll2_conn)
863+
return 0;
864+
847865
if (!QED_LL2_TX_REGISTERED(p_ll2_conn))
848866
return 0;
849867

@@ -1728,6 +1746,8 @@ int qed_ll2_post_rx_buffer(void *cxt,
17281746
if (!p_ll2_conn)
17291747
return -EINVAL;
17301748
p_rx = &p_ll2_conn->rx_queue;
1749+
if (!p_rx->set_prod_addr)
1750+
return -EIO;
17311751

17321752
spin_lock_irqsave(&p_rx->lock, flags);
17331753
if (!list_empty(&p_rx->free_descq))

0 commit comments

Comments
 (0)