From: Zaiyu Wang <zaiyuwang@trustnetic.com>
To: dev@dpdk.org
Cc: Zaiyu Wang <zaiyuwang@trustnetic.com>,
stable@dpdk.org, Jiawen Wu <jiawenwu@trustnetic.com>
Subject: [PATCH 1/2] net/txgbe: fix null pointer check order
Date: Mon, 6 Jul 2026 18:47:18 +0800 [thread overview]
Message-ID: <20260706104723.25968-2-zaiyuwang@trustnetic.com> (raw)
In-Reply-To: <20260706104723.25968-1-zaiyuwang@trustnetic.com>
Move the null pointer check for 'hw' to the beginning of
txgbe_dev_setup_link_alarm_handler_aml() before any dereference
operation.
Currently, 'hw' is dereferenced via hw->dev_back before the
if (!hw) check. This is a reverse NULL check (REVERSE_INULL)
that renders the null pointer validation ineffective and
introduces undefined behavior.
This check serves as a defensive measure against two scenarios:
1. The function is called with a NULL parameter.
2. During application exit, rte_eth_dev_release_port() frees
the port private data (dev_private) while an alarm callback
is still pending or being executed. In such cases, checking
'hw' early helps prevent access to already freed memory.
Coverity issue: 504601
Fixes: 6104fd11086e ("net/txgbe: fix link stability for 25G NIC")
Cc: stable@dpdk.org
Signed-off-by: Zaiyu Wang <zaiyuwang@trustnetic.com>
---
drivers/net/txgbe/txgbe_ethdev.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c
index 9a1cb448ad..4d2746371b 100644
--- a/drivers/net/txgbe/txgbe_ethdev.c
+++ b/drivers/net/txgbe/txgbe_ethdev.c
@@ -3264,15 +3264,16 @@ void
txgbe_dev_setup_link_alarm_handler_aml(void *param)
{
struct txgbe_hw *hw = (struct txgbe_hw *)param;
+
+ if (!hw)
+ return;
+
struct rte_eth_dev *dev = (struct rte_eth_dev *)hw->dev_back;
struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
u32 speed;
bool autoneg = false;
u32 gssr = hw->phy.phy_semaphore_mask;
- if (!hw)
- return;
-
speed = hw->phy.autoneg_advertised;
if (!speed)
hw->mac.get_link_capabilities(hw, &speed, &autoneg);
--
2.21.0.windows.1
next prev parent reply other threads:[~2026-07-06 10:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 10:47 [PATCH 0/2] net/txgbe: fix coverity issues Zaiyu Wang
2026-07-06 10:47 ` Zaiyu Wang [this message]
2026-07-06 10:47 ` [PATCH 2/2] net/txgbe: validate lane_num before GENMASK operations Zaiyu Wang
2026-07-10 11:09 ` [PATCH 0/2] net/txgbe: fix coverity issues Thomas Monjalon
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=20260706104723.25968-2-zaiyuwang@trustnetic.com \
--to=zaiyuwang@trustnetic.com \
--cc=dev@dpdk.org \
--cc=jiawenwu@trustnetic.com \
--cc=stable@dpdk.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