git: 04d4e34538cf - main - iflib: Fix panic during driver reload stress test

From: Eric Joyner <erj_at_FreeBSD.org>
Date: Thu, 27 Jul 2023 22:53:29 UTC
The branch main has been updated by erj:

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

commit 04d4e34538cf8f8ac99b5aa1c6c50b626d976dfd
Author:     Przemyslaw Lewandowski <przemyslawx.lewandowski@intel.com>
AuthorDate: 2023-07-27 22:47:12 +0000
Commit:     Eric Joyner <erj@FreeBSD.org>
CommitDate: 2023-07-27 22:47:12 +0000

    iflib: Fix panic during driver reload stress test
    
    During a driver reload stress test, after 50-300 reloads a panic occurs.
    After adding sleeps in between loading and unloading the driver, the
    issue does not occur.  It's possible that loading/unloading too fast may
    cause the gt_taskqueue pointer to be freed earlier than expected;
    checking for a null pointer first fixes it.
    
    Signed-off-by: Eric Joyner <erj@FreeBSD.org>
    
    Reviewed by:    erj@
    Tested by:      jeffrey.e.pieper@intel.com
    MFC after:      3 days
    Sponsored by:   Intel Corporation
    Differential Revision:  https://reviews.freebsd.org/D39457
---
 sys/net/iflib.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/net/iflib.c b/sys/net/iflib.c
index 9f433481afda..4dd6349f6be1 100644
--- a/sys/net/iflib.c
+++ b/sys/net/iflib.c
@@ -1650,7 +1650,8 @@ iflib_fast_intr_ctx(void *arg)
 			return (result);
 	}
 
-	GROUPTASK_ENQUEUE(gtask);
+	if (gtask->gt_taskqueue != NULL)
+		GROUPTASK_ENQUEUE(gtask);
 	return (FILTER_HANDLED);
 }