[PATCH v2 04/26] net/hinic3: fix vport enable null dereference

Jiacheng Ye yejiacheng4 at h-partners.com
Wed Oct 14 17:09:00 CEST 2026


hinic3_set_vport_enable() dereferences hwdev->dev_handle before checking
hwdev, and then uses nic_dev without validating it. Guard both pointers to
avoid a NULL dereference during early PF initialization.

Fixes: de490215f74a ("net/hinic3: add NIC configuration module")
Cc: stable at dpdk.org

Signed-off-by: Jiacheng Ye <yejiacheng4 at h-partners.com>
---
 drivers/net/hinic3/base/hinic3_nic_cfg.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/hinic3/base/hinic3_nic_cfg.c b/drivers/net/hinic3/base/hinic3_nic_cfg.c
index 5387626b98..d64a123c56 100644
--- a/drivers/net/hinic3/base/hinic3_nic_cfg.c
+++ b/drivers/net/hinic3/base/hinic3_nic_cfg.c
@@ -443,12 +443,15 @@ int
 hinic3_set_vport_enable(struct hinic3_hwdev *hwdev, bool enable)
 {
 	struct hinic3_vport_state en_state;
-	struct hinic3_nic_dev *nic_dev = hwdev->dev_handle;
+	struct hinic3_nic_dev *nic_dev;
 	uint16_t out_size = sizeof(en_state);
 	int err;
 
 	if (!hwdev)
 		return -EINVAL;
+	nic_dev = hwdev->dev_handle;
+	if (!nic_dev)
+		return -EINVAL;
 
 	memset(&en_state, 0, sizeof(en_state));
 	en_state.func_id = hinic3_global_func_id(hwdev);
-- 
2.33.0



More information about the dev mailing list