]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
scsi: megaraid_sas: Fix for a potential deadlock
authorTomas Henzl <thenzl@redhat.com>
Mon, 23 Sep 2024 17:48:33 +0000 (19:48 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 21 Nov 2024 02:53:43 +0000 (21:53 -0500)
This fixes a 'possible circular locking dependency detected' warning
      CPU0                    CPU1
      ----                    ----
 lock(&instance->reset_mutex);
                              lock(&shost->scan_mutex);
                              lock(&instance->reset_mutex);
 lock(&shost->scan_mutex);

Fix this by temporarily releasing the reset_mutex.

Signed-off-by: Tomas Henzl <thenzl@redhat.com>
Link: https://lore.kernel.org/r/20240923174833.45345-1-thenzl@redhat.com
Acked-by: Chandrakanth Patil <chandrakanth.patil@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/megaraid/megaraid_sas_base.c

index 4ecf5284c0fc3460845f2a090ffdeae16696b8c1..6e7e83eaef60f36604c9e2dd94b193d528bff626 100644 (file)
@@ -8907,8 +8907,11 @@ megasas_aen_polling(struct work_struct *work)
                                                   (ld_target_id / MEGASAS_MAX_DEV_PER_CHANNEL),
                                                   (ld_target_id % MEGASAS_MAX_DEV_PER_CHANNEL),
                                                   0);
-                       if (sdev1)
+                       if (sdev1) {
+                               mutex_unlock(&instance->reset_mutex);
                                megasas_remove_scsi_device(sdev1);
+                               mutex_lock(&instance->reset_mutex);
+                       }
 
                        event_type = SCAN_VD_CHANNEL;
                        break;