git: c82c200622b5 - main - Accessing the epoch structure should happen after the INIT_CHECK(). Else the epoch pointer may be NULL.

Hans Petter Selasky hselasky at FreeBSD.org
Fri May 21 09:25:37 UTC 2021


The branch main has been updated by hselasky:

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

commit c82c200622b5380b8346de29879222538653f663
Author:     Hans Petter Selasky <hselasky at FreeBSD.org>
AuthorDate: 2021-05-21 09:06:27 +0000
Commit:     Hans Petter Selasky <hselasky at FreeBSD.org>
CommitDate: 2021-05-21 09:21:32 +0000

    Accessing the epoch structure should happen after the INIT_CHECK().
    Else the epoch pointer may be NULL.
    
    MFC after:      1 week
    Sponsored by:   Mellanox Technologies // NVIDIA Networking
---
 sys/kern/subr_epoch.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/kern/subr_epoch.c b/sys/kern/subr_epoch.c
index c5e4b78d8b79..798dbdc4360e 100644
--- a/sys/kern/subr_epoch.c
+++ b/sys/kern/subr_epoch.c
@@ -442,13 +442,14 @@ _epoch_enter_preempt(epoch_t epoch, epoch_tracker_t et EPOCH_FILE_LINE)
 	struct thread *td;
 
 	MPASS(cold || epoch != NULL);
-	MPASS(epoch->e_flags & EPOCH_PREEMPT);
 	td = curthread;
 	MPASS((vm_offset_t)et >= td->td_kstack &&
 	    (vm_offset_t)et + sizeof(struct epoch_tracker) <=
 	    td->td_kstack + td->td_kstack_pages * PAGE_SIZE);
 
 	INIT_CHECK(epoch);
+	MPASS(epoch->e_flags & EPOCH_PREEMPT);
+
 #ifdef EPOCH_TRACE
 	epoch_trace_enter(td, epoch, et, file, line);
 #endif


More information about the dev-commits-src-main mailing list