]> git.baikalelectronics.ru Git - kernel.git/commitdiff
scsi: smartpqi: Fix rmmod stack trace
authorDon Brace <don.brace@microchip.com>
Tue, 1 Feb 2022 21:47:53 +0000 (15:47 -0600)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 8 Feb 2022 04:38:33 +0000 (23:38 -0500)
Prevent "BUG: scheduling while atomic: rmmod" stack trace.

Stop setting spin_locks before calling OS functions to remove devices.

Link: https://lore.kernel.org/r/164375207296.440833.4996145011193819683.stgit@brunhilda.pdev.net
Reviewed-by: Scott Benesh <scott.benesh@microchip.com>
Reviewed-by: Scott Teel <scott.teel@microchip.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microchip.com>
Signed-off-by: Don Brace <don.brace@microchip.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/smartpqi/smartpqi_init.c

index f0897d587454abf78ad5e203b711539a3a6dbfe3..2db9f874cc51f1aea630d12deb86c1f4e1998a03 100644 (file)
@@ -2513,17 +2513,15 @@ static void pqi_remove_all_scsi_devices(struct pqi_ctrl_info *ctrl_info)
        struct pqi_scsi_dev *device;
        struct pqi_scsi_dev *next;
 
-       spin_lock_irqsave(&ctrl_info->scsi_device_list_lock, flags);
-
        list_for_each_entry_safe(device, next, &ctrl_info->scsi_device_list,
                scsi_device_list_entry) {
                if (pqi_is_device_added(device))
                        pqi_remove_device(ctrl_info, device);
+               spin_lock_irqsave(&ctrl_info->scsi_device_list_lock, flags);
                list_del(&device->scsi_device_list_entry);
                pqi_free_device(device);
+               spin_unlock_irqrestore(&ctrl_info->scsi_device_list_lock, flags);
        }
-
-       spin_unlock_irqrestore(&ctrl_info->scsi_device_list_lock, flags);
 }
 
 static int pqi_scan_scsi_devices(struct pqi_ctrl_info *ctrl_info)