git: da2e35b0ec99 - releng/13.3 - smartpqi: Drop spinlock before freeing memory

From: Warner Losh <imp_at_FreeBSD.org>
Date: Mon, 19 Feb 2024 07:00:26 UTC
The branch releng/13.3 has been updated by imp:

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

commit da2e35b0ec99e979963923ed6392b3e883f40eb2
Author:     John F. Carr <jfc@mit.edu>
AuthorDate: 2023-10-19 03:02:42 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-02-19 06:59:36 +0000

    smartpqi: Drop spinlock before freeing memory
    
    pqisrc_free_device frees the device softc with the os spinlock
    held. This causes crashes when devices are removed because the memory
    free might sleep (which is prohibited with spin locks held). Drop the
    spinlock before releasing the memory.
    
    MFC After: 2 days
    PR: 273289
    Reviewed by: imp
    
    This is the alternate fix from the box.
    
    (this is not a cherry pick of b064a4c9eed5b1dd2a40fc4fd2cb7e738b681547)
    
    (cherry picked from commit 898e02d740741d13a8948cbad4e0d969a768fd30)
    
    Approved-by: re (cperciva)
---
 sys/dev/smartpqi/smartpqi_discovery.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sys/dev/smartpqi/smartpqi_discovery.c b/sys/dev/smartpqi/smartpqi_discovery.c
index 48243d8fc882..08722a35b707 100644
--- a/sys/dev/smartpqi/smartpqi_discovery.c
+++ b/sys/dev/smartpqi/smartpqi_discovery.c
@@ -1460,10 +1460,9 @@ pqisrc_free_device(pqisrc_softstate_t * softs,pqi_scsi_dev_t *device)
 
 	softs->device_list[device->target][device->lun] = NULL;
 
-	pqisrc_device_mem_free(softs, device);
-
 	OS_RELEASE_SPINLOCK(&softs->devlist_lock);
 
+	pqisrc_device_mem_free(softs, device);
 }
 
 /* Update the newly added devices to the device list */