Hello Damien Le Moal, Commit 0c76106cb975 ("scsi: sd: Fix TCG OPAL unlock on system resume") from Mar 19, 2024 (linux-next), leads to the following Smatch static checker warning: drivers/ata/libata-scsi.c:4774 ata_scsi_dev_rescan() error: double unlocked 'ap->lock' (orig line 4757) drivers/ata/libata-scsi.c 4726 void ata_scsi_dev_rescan(struct work_struct *work) 4727 { 4728 struct ata_port *ap = 4729 container_of(work, struct ata_port, scsi_rescan_task.work); 4730 struct ata_link *link; 4731 struct ata_device *dev; 4732 unsigned long flags; 4733 bool do_resume; 4734 int ret = 0; 4735 4736 mutex_lock(&ap->scsi_scan_mutex); 4737 spin_lock_irqsave(ap->lock, flags); 4738 4739 ata_for_each_link(link, ap, EDGE) { 4740 ata_for_each_dev(dev, link, ENABLED) { 4741 struct scsi_device *sdev = dev->sdev; 4742 4743 /* 4744 * If the port was suspended before this was scheduled, 4745 * bail out. 4746 */ 4747 if (ap->pflags & ATA_PFLAG_SUSPENDED) 4748 goto unlock; 4749 4750 if (!sdev) 4751 continue; 4752 if (scsi_device_get(sdev)) 4753 continue; 4754 4755 do_resume = dev->flags & ATA_DFLAG_RESUMING; 4756 4757 spin_unlock_irqrestore(ap->lock, flags); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 4758 if (do_resume) { 4759 ret = scsi_resume_device(sdev); 4760 if (ret == -EWOULDBLOCK) 4761 goto unlock; ^^^^^^^^^^^^ 4762 dev->flags &= ~ATA_DFLAG_RESUMING; 4763 } 4764 ret = scsi_rescan_device(sdev); 4765 scsi_device_put(sdev); 4766 spin_lock_irqsave(ap->lock, flags); 4767 4768 if (ret) 4769 goto unlock; 4770 } 4771 } 4772 4773 unlock: --> 4774 spin_unlock_irqrestore(ap->lock, flags); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Double unlock 4775 mutex_unlock(&ap->scsi_scan_mutex); 4776 4777 /* Reschedule with a delay if scsi_rescan_device() returned an error */ 4778 if (ret) 4779 schedule_delayed_work(&ap->scsi_rescan_task, 4780 msecs_to_jiffies(5)); 4781 } regards, dan carpenter