nvme: fail SCSI read/write command with unsupported protection bit
[deliverable/linux.git] / drivers / block / nvme-scsi.c
index f53da60b657db3647693f123c73a567e2213579e..342f5b7f840dca840189ded73f79ff71815d5c7f 100644 (file)
@@ -1900,6 +1900,13 @@ static int nvme_trans_io(struct nvme_ns *ns, struct sg_io_hdr *hdr, u8 is_write,
        default:
                cdb_info.fua = cmd[1] & 0x8;
                cdb_info.prot_info = (cmd[1] & 0xe0) >> 5;
+               if (cdb_info.prot_info && !ns->pi_type) {
+                       return nvme_trans_completion(hdr,
+                                       SAM_STAT_CHECK_CONDITION,
+                                       ILLEGAL_REQUEST,
+                                       SCSI_ASC_INVALID_CDB,
+                                       SCSI_ASCQ_CAUSE_NOT_REPORTABLE);
+               }
        }
 
        switch (opcode) {
This page took 0.029388 seconds and 5 git commands to generate.