git: 4ad47cfc1458 - stable/13 - iflib: Add null check to iflib_stop()

From: Eric Joyner <erj_at_FreeBSD.org>
Date: Tue, 07 Feb 2023 00:16:16 UTC
The branch stable/13 has been updated by erj:

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

commit 4ad47cfc1458263564dfecf483c5dfc253008b6f
Author:     Przemyslaw Lewandowski <przemyslawx.lewandowski@intel.com>
AuthorDate: 2023-01-24 23:41:15 +0000
Commit:     Eric Joyner <erj@FreeBSD.org>
CommitDate: 2023-02-07 00:16:02 +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
    
    (cherry picked from commit 9147969bc277b389a62373c6a5050a2ebfd39071)
---
 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 39072eedc0bb..748970a58f3f 100644
--- a/sys/net/iflib.c
+++ b/sys/net/iflib.c
@@ -2613,8 +2613,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++)