]> git.apps.os.sepia.ceph.com Git - ceph-client.git/commitdiff
scsi: core: Fix missing lock protection
authorChaohai Chen <wdhh66@163.com>
Fri, 21 Feb 2025 03:07:55 +0000 (11:07 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Mon, 3 Mar 2025 02:06:02 +0000 (21:06 -0500)
async_scan_lock is designed to protect the scanning_hosts list, but there
is no protection here.

Signed-off-by: Chaohai Chen <wdhh66@163.com>
Link: https://lore.kernel.org/r/20250221030755.219277-1-wdhh66@163.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/scsi_scan.c

index 96d7e1a9a7c7a2234274aca3af81f6fae97c7777..4833b8fe251b885d6edfcbdbd6bfcb3f16975fdd 100644 (file)
@@ -151,8 +151,9 @@ int scsi_complete_async_scans(void)
        struct async_scan_data *data;
 
        do {
-               if (list_empty(&scanning_hosts))
-                       return 0;
+               scoped_guard(spinlock, &async_scan_lock)
+                       if (list_empty(&scanning_hosts))
+                               return 0;
                /* If we can't get memory immediately, that's OK.  Just
                 * sleep a little.  Even if we never get memory, the async
                 * scans will finish eventually.