git: ae122c544388 - main - ixl: Initialize VF sysctl contexts before use

From: Kevin Bowling <kbowling_at_FreeBSD.org>
Date: Mon, 10 Aug 2026 08:49:36 UTC
The branch main has been updated by kbowling:

URL: https://cgit.FreeBSD.org/src/commit/?id=ae122c5443882ae4d3d19aacfcfd16a2c8d7b688

commit ae122c5443882ae4d3d19aacfcfd16a2c8d7b688
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2026-08-10 04:53:08 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-08-10 08:44:53 +0000

    ixl: Initialize VF sysctl contexts before use
    
    The VF array is zeroed at allocation, but its sysctl contexts were
    only populated after each VF was successfully added.  If VF setup
    failed, IOV teardown still passed every requested VF context to
    sysctl_ctx_free().  An untouched context is not an initialized empty
    TAILQ and caused a page fault during teardown.
    
    Initialize every VF context with the array so both successful setup
    and partial-failure cleanup have a valid lifetime.
    
    MFC after:      2 weeks
---
 sys/dev/ixl/ixl_pf_iov.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sys/dev/ixl/ixl_pf_iov.c b/sys/dev/ixl/ixl_pf_iov.c
index de8e2c27b9eb..e749797fa700 100644
--- a/sys/dev/ixl/ixl_pf_iov.c
+++ b/sys/dev/ixl/ixl_pf_iov.c
@@ -1654,7 +1654,7 @@ ixl_if_iov_init(if_ctx_t ctx, uint16_t num_vfs, const nvlist_t *params)
 	struct i40e_hw *hw;
 	struct ixl_vsi *pf_vsi;
 	enum i40e_status_code ret;
-	int error;
+	int error, i;
 
 	hw = &pf->hw;
 	pf_vsi = &pf->vsi;
@@ -1665,6 +1665,8 @@ ixl_if_iov_init(if_ctx_t ctx, uint16_t num_vfs, const nvlist_t *params)
 		error = ENOMEM;
 		goto fail;
 	}
+	for (i = 0; i < num_vfs; i++)
+		sysctl_ctx_init(&pf->vfs[i].vsi.sysctl_ctx);
 
 	/*
 	 * Add the VEB and ...