Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f1a0db49 authored by Shai Malin's avatar Shai Malin Committed by Greg Kroah-Hartman
Browse files

qed: qed ll2 race condition fixes



[ Upstream commit 37110237f31105d679fc0aa7b11cdec867750ea7 ]

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: default avatarAriel Elior <aelior@marvell.com>
Signed-off-by: default avatarShai Malin <smalin@marvell.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 73ba9e4e
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -353,6 +353,9 @@ static int qed_ll2_txq_completion(struct qed_hwfn *p_hwfn, void *p_cookie)
	unsigned long flags;
	int rc = -EINVAL;

	if (!p_ll2_conn)
		return rc;

	spin_lock_irqsave(&p_tx->lock, flags);
	if (p_tx->b_completing_packet) {
		rc = -EBUSY;
@@ -526,7 +529,16 @@ static int qed_ll2_rxq_completion(struct qed_hwfn *p_hwfn, void *cookie)
	unsigned long flags = 0;
	int rc = 0;

	if (!p_ll2_conn)
		return rc;

	spin_lock_irqsave(&p_rx->lock, flags);

	if (!QED_LL2_RX_REGISTERED(p_ll2_conn)) {
		spin_unlock_irqrestore(&p_rx->lock, flags);
		return 0;
	}

	cq_new_idx = le16_to_cpu(*p_rx->p_fw_cons);
	cq_old_idx = qed_chain_get_cons_idx(&p_rx->rcq_chain);

@@ -847,6 +859,9 @@ static int qed_ll2_lb_rxq_completion(struct qed_hwfn *p_hwfn, void *p_cookie)
	struct qed_ll2_info *p_ll2_conn = (struct qed_ll2_info *)p_cookie;
	int rc;

	if (!p_ll2_conn)
		return 0;

	if (!QED_LL2_RX_REGISTERED(p_ll2_conn))
		return 0;

@@ -870,6 +885,9 @@ static int qed_ll2_lb_txq_completion(struct qed_hwfn *p_hwfn, void *p_cookie)
	u16 new_idx = 0, num_bds = 0;
	int rc;

	if (!p_ll2_conn)
		return 0;

	if (!QED_LL2_TX_REGISTERED(p_ll2_conn))
		return 0;

@@ -1642,6 +1660,8 @@ int qed_ll2_post_rx_buffer(void *cxt,
	if (!p_ll2_conn)
		return -EINVAL;
	p_rx = &p_ll2_conn->rx_queue;
	if (!p_rx->set_prod_addr)
		return -EIO;

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