[PATCH] scsi: fix schedule_work in spin_lock_irqsave in sdev_evt_send

From: Chaohai Chen
Date: Tue Feb 25 2025 - 22:38:20 EST


sdev->list_lock is designed to protect the sdev->event_list, the action
should be single(add, delete, traverse) in the lock.

Signed-off-by: Chaohai Chen <wdhh6@xxxxxxxxxx>
---
drivers/scsi/scsi_lib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index be0890e4e706..ca1bbd5e38c0 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2661,8 +2661,8 @@ void sdev_evt_send(struct scsi_device *sdev, struct scsi_event *evt)

spin_lock_irqsave(&sdev->list_lock, flags);
list_add_tail(&evt->node, &sdev->event_list);
- schedule_work(&sdev->event_work);
spin_unlock_irqrestore(&sdev->list_lock, flags);
+ schedule_work(&sdev->event_work);
}
EXPORT_SYMBOL_GPL(sdev_evt_send);

--
2.34.1