From: Wentao Liang <vulab@iscas.ac.cn>
To: pavan.chebbi@broadcom.com, mchan@broadcom.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>
Subject: [PATCH] tg3: Check return value of tg3_nvram_lock before resetting lock
Date: Tue, 11 Feb 2025 23:26:58 +0800 [thread overview]
Message-ID: <20250211152658.1094-1-vulab@iscas.ac.cn> (raw)
The current code does not check the return value of tg3_nvram_lock before
resetting the lock count (tp->nvram_lock_cnt = 0). This is dangerous
because if tg3_nvram_lock fails, the lock state may be inconsistent,
leading to potential race conditions or undefined behavior.
This patch adds a check for the return value of tg3_nvram_lock. If the
function fails, the error is propagated to the caller, ensuring that
the lock state remains consistent.
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/net/ethernet/broadcom/tg3.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 9cc8db10a8d6..851d19b3f43c 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -9160,7 +9160,9 @@ static int tg3_chip_reset(struct tg3 *tp)
if (!pci_device_is_present(tp->pdev))
return -ENODEV;
- tg3_nvram_lock(tp);
+ err = tg3_nvram_lock(tp);
+ if (err)
+ return err;
tg3_ape_lock(tp, TG3_APE_LOCK_GRC);
--
2.42.0.windows.2
next reply other threads:[~2025-02-11 15:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-11 15:26 Wentao Liang [this message]
2025-02-11 19:33 ` [PATCH] tg3: Check return value of tg3_nvram_lock before resetting lock Joe Damato
2025-02-11 21:50 ` Michael Chan
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=20250211152658.1094-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mchan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pavan.chebbi@broadcom.com \
/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