git: 241d13765504 - stable/12 - ocs_fc: Fix a use after free in ocs_sport_free

From: Ram Kishore Vegesna <ram_at_FreeBSD.org>
Date: Fri, 17 Dec 2021 10:03:46 UTC
The branch stable/12 has been updated by ram:

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

commit 241d1376550452d2da5eb80e9ee5d84ae567dd7b
Author:     Ram Kishore Vegesna <ram@FreeBSD.org>
AuthorDate: 2021-05-28 05:26:13 +0000
Commit:     Ram Kishore Vegesna <ram@FreeBSD.org>
CommitDate: 2021-12-17 09:45:59 +0000

    ocs_fc: Fix a use after free in ocs_sport_free
    
    Domain which could be freed is used while freeing the sport.
    Use ocs from sport.
    
    PR: 255866
    Reported by: lylgood@foxmail.com
    Approved by:: markj
    
    (cherry picked from commit dd722ccd6efcaed5c6056e51a044db7f1a5b4a0d)
---
 sys/dev/ocs_fc/ocs_sport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/dev/ocs_fc/ocs_sport.c b/sys/dev/ocs_fc/ocs_sport.c
index 8031dc8f3692..6ca64adda089 100644
--- a/sys/dev/ocs_fc/ocs_sport.c
+++ b/sys/dev/ocs_fc/ocs_sport.c
@@ -264,7 +264,7 @@ ocs_sport_free(ocs_sport_t *sport)
 		ocs_lock_free(&sport->node_group_lock);
 		ocs_scsi_sport_deleted(sport);
 
-		ocs_free(domain->ocs, sport, sizeof(*sport));
+		ocs_free(sport->ocs, sport, sizeof(*sport));
 		
 	}
 }