git: 8252fe56a0ed - main - cam: Fix race condition in dainit()

Edward Tomasz Napierala trasz at FreeBSD.org
Sun May 16 12:40:50 UTC 2021


The branch main has been updated by trasz:

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

commit 8252fe56a0edc95f55b203424a8f2f957959e7a4
Author:     Edward Tomasz Napierala <trasz at FreeBSD.org>
AuthorDate: 2021-05-16 09:35:31 +0000
Commit:     Edward Tomasz Napierala <trasz at FreeBSD.org>
CommitDate: 2021-05-16 12:36:54 +0000

    cam: Fix race condition in dainit()
    
    Previously, daregister() could have been called before dainit()
    initialized the UMA zone.  This would trip a KASSERT.
    
    Reported By:    pho
    Tested By:      pho
    Sponsored by:   NetApp, Inc.
    Sponsored by:   Klara, Inc.
---
 sys/cam/scsi/scsi_da.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c
index 05dd9b6e7566..cf6e2e17e410 100644
--- a/sys/cam/scsi/scsi_da.c
+++ b/sys/cam/scsi/scsi_da.c
@@ -2001,6 +2001,10 @@ dainit(void)
 {
 	cam_status status;
 
+	da_ccb_zone = uma_zcreate("da_ccb",
+	    sizeof(struct ccb_scsiio), NULL, NULL, NULL, NULL,
+	    UMA_ALIGN_PTR, 0);
+
 	/*
 	 * Install a global async callback.  This callback will
 	 * receive async callbacks like "new device found".
@@ -2016,10 +2020,6 @@ dainit(void)
 					   NULL, SHUTDOWN_PRI_DEFAULT)) == NULL)
 		    printf("dainit: shutdown event registration failed!\n");
 	}
-
-	da_ccb_zone = uma_zcreate("da_ccb",
-	    sizeof(struct ccb_scsiio), NULL, NULL, NULL, NULL,
-	    UMA_ALIGN_PTR, 0);
 }
 
 /*


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