git: 9147969bc277 - main - iflib: Add null check to iflib_stop()

From: Eric Joyner <erj_at_FreeBSD.org>
Date: Tue, 24 Jan 2023 23:46:29 UTC
The branch main has been updated by erj:

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

commit 9147969bc277b389a62373c6a5050a2ebfd39071
Author:     Przemyslaw Lewandowski <przemyslawx.lewandowski@intel.com>
AuthorDate: 2023-01-24 23:41:15 +0000
Commit:     Eric Joyner <erj@FreeBSD.org>
CommitDate: 2023-01-24 23:45:15 +0000

    iflib: Add null check to iflib_stop()
    
    Ever since gtaskqueue_drain() was added to iflib_stop(), a kernel panic
    occurs when the ice(4) driver is in recovery mode. Queues are not
    initialized in this mode, so gt_taskqueue is not initialized, and
    gtaskqueue_drain() will panic.
    
    Fix this by only doing a drain if an RX queue's gt_taskqueue is
    initialized.
    
    Signed-off-by: Eric Joyner <erj@FreeBSD.org>
    
    Reviewed by:    erj@
    MFC after:      1 week
    Sponsored by:   Intel Corporation
    Differential Revision:  https://reviews.freebsd.org/D37892
---
 sys/net/iflib.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sys/net/iflib.c b/sys/net/iflib.c
index 5f202b120005..0a500f8e2810 100644
--- a/sys/net/iflib.c
+++ b/sys/net/iflib.c
@@ -2644,8 +2644,9 @@ iflib_stop(if_ctx_t ctx)
 			bzero((void *)di->idi_vaddr, di->idi_size);
 	}
 	for (i = 0; i < scctx->isc_nrxqsets; i++, rxq++) {
-		gtaskqueue_drain(rxq->ifr_task.gt_taskqueue,
-		    &rxq->ifr_task.gt_task);
+		if (rxq->ifr_task.gt_taskqueue != NULL)
+			gtaskqueue_drain(rxq->ifr_task.gt_taskqueue,
+				 &rxq->ifr_task.gt_task);
 
 		rxq->ifr_cq_cidx = 0;
 		for (j = 0, di = rxq->ifr_ifdi; j < sctx->isc_nrxqs; j++, di++)