LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Shai Malin <smalin@marvell.com>, Ariel Elior <aelior@marvell.com>,
	"David S . Miller" <davem@davemloft.net>,
	Sasha Levin <sashal@kernel.org>,
	netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 5.10 09/18] qed: qed ll2 race condition fixes
Date: Mon, 23 Aug 2021 20:54:23 -0400	[thread overview]
Message-ID: <20210824005432.631154-9-sashal@kernel.org> (raw)
In-Reply-To: <20210824005432.631154-1-sashal@kernel.org>

From: Shai Malin <smalin@marvell.com>

[ 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: Ariel Elior <aelior@marvell.com>
Signed-off-by: Shai Malin <smalin@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/qlogic/qed/qed_ll2.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_ll2.c b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
index 49783f365079..f2c8273dce67 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_ll2.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
@@ -327,6 +327,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;
@@ -500,7 +503,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);
 
@@ -821,6 +833,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;
 
@@ -844,6 +859,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;
 
@@ -1725,6 +1743,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))
-- 
2.30.2


  parent reply	other threads:[~2021-08-24  0:57 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-24  0:54 [PATCH AUTOSEL 5.10 01/18] iwlwifi: pnvm: accept multiple HW-type TLVs Sasha Levin
2021-08-24  0:54 ` [PATCH AUTOSEL 5.10 02/18] opp: remove WARN when no valid OPPs remain Sasha Levin
2021-08-24  0:54 ` [PATCH AUTOSEL 5.10 03/18] cpufreq: blocklist Qualcomm sm8150 in cpufreq-dt-platdev Sasha Levin
2021-08-24  0:54 ` [PATCH AUTOSEL 5.10 04/18] virtio: Improve vq->broken access to avoid any compiler optimization Sasha Levin
2021-08-24  0:54 ` [PATCH AUTOSEL 5.10 05/18] virtio_pci: Support surprise removal of virtio pci device Sasha Levin
2021-08-24  0:54 ` [PATCH AUTOSEL 5.10 06/18] virtio_vdpa: reject invalid vq indices Sasha Levin
2021-08-24  0:54 ` [PATCH AUTOSEL 5.10 07/18] vringh: Use wiov->used to check for read/write desc order Sasha Levin
2021-08-24  0:54 ` [PATCH AUTOSEL 5.10 08/18] tools/virtio: fix build Sasha Levin
2021-08-24  0:54 ` Sasha Levin [this message]
2021-08-24  0:54 ` [PATCH AUTOSEL 5.10 10/18] qed: Fix null-pointer dereference in qed_rdma_create_qp() Sasha Levin
2021-08-24  0:54 ` [PATCH AUTOSEL 5.10 11/18] Revert "drm/amd/pm: fix workload mismatch on vega10" Sasha Levin
2021-08-24  0:54 ` [PATCH AUTOSEL 5.10 12/18] drm/amd/pm: change the workload type for some cards Sasha Levin
2021-08-24  0:54 ` [PATCH AUTOSEL 5.10 13/18] blk-mq: don't grab rq's refcount in blk_mq_check_expired() Sasha Levin
2021-08-24  0:54 ` [PATCH AUTOSEL 5.10 14/18] drm: Copy drm_wait_vblank to user before returning Sasha Levin
2021-08-24  0:54 ` [PATCH AUTOSEL 5.10 15/18] drm/nouveau/disp: power down unused DP links during init Sasha Levin
2021-08-24  0:54 ` [PATCH AUTOSEL 5.10 16/18] drm/nouveau/kms/nv50: workaround EFI GOP window channel format differences Sasha Levin
2021-08-24 17:07   ` Lyude Paul
2021-08-24  0:54 ` [PATCH AUTOSEL 5.10 17/18] drm/nouveau: block a bunch of classes from userspace Sasha Levin
2021-08-24  0:54 ` [PATCH AUTOSEL 5.10 18/18] net/rds: dma_map_sg is entitled to merge entries Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210824005432.631154-9-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=aelior@marvell.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=smalin@marvell.com \
    --cc=stable@vger.kernel.org \
    --subject='Re: [PATCH AUTOSEL 5.10 09/18] qed: qed ll2 race condition fixes' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).