mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wentao Liang <vulab@iscas.ac.cn>
To: rmody@marvell.com, GR-Linux-NIC-Dev@marvell.com,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Wentao Liang <vulab@iscas.ac.cn>,
	stable@vger.kernel.org
Subject: [PATCH] bnx2: fix refcount leak in bnx2_change_ring_size()
Date: Tue,  9 Jun 2026 07:47:46 +0000	[thread overview]
Message-ID: <20260609074746.206312-1-vulab@iscas.ac.cn> (raw)

The error path in bnx2_change_ring_size() when reopening the
device fails does not balance the intr_sem semaphore.
bnx2_netif_stop(true) increments the semaphore at the start of the
function if the netif is running. On success, bnx2_netif_start(true)
decrements it. However, when bnx2_alloc_mem(), bnx2_request_irq(),
or bnx2_init_nic() fail, the error handling calls bnx2_napi_enable()
and dev_close() without performing the corresponding decrement. This
leaves the semaphore permanently imbalanced, eventually causing
stall or deadlock on subsequent internal synchronization.

Fix this by calling bnx2_netif_start(true) in the error path to
properly release the semaphore count.

Cc: stable@vger.kernel.org
Fixes: 6fefb65e78f0 ("bnx2: Close device if MTU change or ring size change fails.")
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/net/ethernet/broadcom/bnx2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c
index f5722e929833..7f8ade29b7e5 100644
--- a/drivers/net/ethernet/broadcom/bnx2.c
+++ b/drivers/net/ethernet/broadcom/bnx2.c
@@ -7360,6 +7360,7 @@ bnx2_change_ring_size(struct bnx2 *bp, u32 rx, u32 tx, bool reset_irq)
 		if (rc) {
 			bnx2_napi_enable(bp);
 			dev_close(bp->dev);
+			atomic_dec(&bp->intr_sem);
 			return rc;
 		}
 #ifdef BCM_CNIC
-- 
2.34.1


             reply	other threads:[~2026-06-09  7:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-09  7:47 Wentao Liang [this message]
2026-06-11 15:13 ` Simon Horman

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=20260609074746.206312-1-vulab@iscas.ac.cn \
    --to=vulab@iscas.ac.cn \
    --cc=GR-Linux-NIC-Dev@marvell.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rmody@marvell.com \
    --cc=stable@vger.kernel.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®