]> Git Repo - linux.git/commitdiff
scsi: sd: Clear sdkp->protection_type if disk is reformatted without PI
authorXiang Chen <[email protected]>
Thu, 9 Jan 2020 01:12:24 +0000 (09:12 +0800)
committerMartin K. Petersen <[email protected]>
Fri, 10 Jan 2020 06:28:56 +0000 (01:28 -0500)
If an attached disk with protection information enabled is reformatted
to Type 0 the revalidation code does not clear the original protection
type and subsequent accesses will keep setting RDPROTECT/WRPROTECT.

Set the protection type to 0 if the disk reports PROT_EN=0 in READ
CAPACITY(16).

[mkp: commit desc]

Fixes: fe542396da73 ("[SCSI] sd: Ensure we correctly disable devices with unknown protection type")
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Xiang Chen <[email protected]>
Signed-off-by: Martin K. Petersen <[email protected]>
drivers/scsi/sd.c

index cea625906440ab6f50f16006e4056196b7cb4f99..65ce10c7989ca3a36fab578042b6281e566d47f1 100644 (file)
@@ -2211,8 +2211,10 @@ static int sd_read_protection_type(struct scsi_disk *sdkp, unsigned char *buffer
        u8 type;
        int ret = 0;
 
-       if (scsi_device_protection(sdp) == 0 || (buffer[12] & 1) == 0)
+       if (scsi_device_protection(sdp) == 0 || (buffer[12] & 1) == 0) {
+               sdkp->protection_type = 0;
                return ret;
+       }
 
        type = ((buffer[12] >> 1) & 7) + 1; /* P_TYPE 0 = Type 1 */
 
This page took 0.055825 seconds and 4 git commands to generate.