]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ata: libata-scsi: Fix ata_scsi_dev_rescan() error path
authorDamien Le Moal <dlemoal@kernel.org>
Thu, 11 Apr 2024 23:41:15 +0000 (08:41 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Apr 2024 09:19:25 +0000 (11:19 +0200)
commit341b5e1016cfc5c6bdaa6103204d181d11fa6aaa
treeeace29a99f24c845cee856f9b1d74117a6fef7c5
parent99618f8a7216a07b83bb0dcf9de92d0deed46595
ata: libata-scsi: Fix ata_scsi_dev_rescan() error path

commit 79336504781e7fee5ddaf046dcc186c8dfdf60b1 upstream.

Commit 0c76106cb975 ("scsi: sd: Fix TCG OPAL unlock on system resume")
incorrectly handles failures of scsi_resume_device() in
ata_scsi_dev_rescan(), leading to a double call to
spin_unlock_irqrestore() to unlock a device port. Fix this by redefining
the goto labels used in case of errors and only unlock the port
scsi_scan_mutex when scsi_resume_device() fails.

Bug found with the Smatch static checker warning:

drivers/ata/libata-scsi.c:4774 ata_scsi_dev_rescan()
error: double unlocked 'ap->lock' (orig line 4757)

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Fixes: 0c76106cb975 ("scsi: sd: Fix TCG OPAL unlock on system resume")
Cc: stable@vger.kernel.org
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Niklas Cassel <cassel@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/ata/libata-scsi.c