git: 8a6c20aee2fa - stable/15 - igb: Guard register dump during queue setup

From: Kevin Bowling <kbowling_at_FreeBSD.org>
Date: Sun, 30 Aug 2026 01:43:35 UTC
The branch stable/15 has been updated by kbowling:

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

commit 8a6c20aee2fae9bca0c81dde271f7362c9ac3bb3
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2026-07-30 02:26:48 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-08-30 01:43:22 +0000

    igb: Guard register dump during queue setup
    
    The register-dump sysctl is installed before iflib allocates the queue
    arrays and remains visible while they are freed. Return ENXIO outside
    the queue lifetime instead of dereferencing a NULL or stale array.
    
    Sponsored by:   BBOX.io
    
    (cherry picked from commit bcb62ec0e3d592892f0f304269ed2722d1bae75a)
---
 sys/dev/e1000/if_em.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c
index 93bab0e65ee6..99495e93d265 100644
--- a/sys/dev/e1000/if_em.c
+++ b/sys/dev/e1000/if_em.c
@@ -795,6 +795,13 @@ static int em_get_regs(SYSCTL_HANDLER_ARGS)
 	u32 *regs_buff;
 	int rc;
 
+	/*
+	 * This sysctl is registered before iflib allocates the queue arrays,
+	 * and remains registered while iflib tears them down.
+	 */
+	if (sc->rx_queues == NULL || sc->tx_queues == NULL)
+		return (ENXIO);
+
 	regs_buff = malloc(sizeof(u32) * IGB_REGS_LEN, M_DEVBUF, M_WAITOK);
 	memset(regs_buff, 0, IGB_REGS_LEN * sizeof(u32));