From: Oliver Neukum Date: Tue, 3 Sep 2019 10:18:39 +0000 (+0200) Subject: scsi: sd: Ignore a failure to sync cache due to lack of authorization X-Git-Tag: v3.16.80~131 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc0104b28a60413fc7d2d83c5a32522e1550a8d4;p=thirdparty%2Fkernel%2Fstable.git scsi: sd: Ignore a failure to sync cache due to lack of authorization commit 21e3d6c81179bbdfa279efc8de456c34b814cfd2 upstream. I've got a report about a UAS drive enclosure reporting back Sense: Logical unit access not authorized if the drive it holds is password protected. While the drive is obviously unusable in that state as a mass storage device, it still exists as a sd device and when the system is asked to perform a suspend of the drive, it will be sent a SYNCHRONIZE CACHE. If that fails due to password protection, the error must be ignored. Link: https://lore.kernel.org/r/20190903101840.16483-1-oneukum@suse.com Signed-off-by: Oliver Neukum Signed-off-by: Martin K. Petersen [bwh: Backported to 3.16: sshdr is a struct not a pointer here] Signed-off-by: Ben Hutchings --- diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 228d8250e4520..2fcda75ef6886 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1470,7 +1470,8 @@ static int sd_sync_cache(struct scsi_disk *sdkp) /* we need to evaluate the error return */ if (scsi_sense_valid(&sshdr) && (sshdr.asc == 0x3a || /* medium not present */ - sshdr.asc == 0x20)) /* invalid command */ + sshdr.asc == 0x20 || /* invalid command */ + (sshdr.asc == 0x74 && sshdr.ascq == 0x71))) /* drive is password locked */ /* this is no error here */ return 0;