aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Bowling <kbowling@FreeBSD.org>2026-07-30 02:26:48 +0000
committerKevin Bowling <kbowling@FreeBSD.org>2026-07-30 02:47:33 +0000
commitbcb62ec0e3d592892f0f304269ed2722d1bae75a (patch)
tree8322f73fca697e19ad009caccdc9a6350214ad33
parent7eb7ff6459219e802d51add3ba9d1d9d874db561 (diff)
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
-rw-r--r--sys/dev/e1000/if_em.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c
index eaaa7c5fd2f0..42e7113bff48 100644
--- a/sys/dev/e1000/if_em.c
+++ b/sys/dev/e1000/if_em.c
@@ -845,6 +845,13 @@ static int em_get_regs(SYSCTL_HANDLER_ARGS)
int rc;
uint32_t rxqid, txqid;
+ /*
+ * 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));
rxqid = sc->rx_queues[0].rxr.me;