Skip to content

Commit 465f4ed

Browse files
Xiang Chenmartinkpetersen
authored andcommitted
scsi: sd: Clear sdkp->protection_type if disk is reformatted without PI
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: fe54239 ("[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]>
1 parent e4dc9a4 commit 465f4ed

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/scsi/sd.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2211,8 +2211,10 @@ static int sd_read_protection_type(struct scsi_disk *sdkp, unsigned char *buffer
22112211
u8 type;
22122212
int ret = 0;
22132213

2214-
if (scsi_device_protection(sdp) == 0 || (buffer[12] & 1) == 0)
2214+
if (scsi_device_protection(sdp) == 0 || (buffer[12] & 1) == 0) {
2215+
sdkp->protection_type = 0;
22152216
return ret;
2217+
}
22162218

22172219
type = ((buffer[12] >> 1) & 7) + 1; /* P_TYPE 0 = Type 1 */
22182220

0 commit comments

Comments
 (0)