[PATCH 2/3] [SCSI] ufs: Limit sense data size to 18 bytes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



As per the UFS specification a UFS device server should return upto
18 bytes of sense data. Currently, if a SCSI command completes with
a check condition, min_t(sense_data_length, SCSI_SENSE_BUFFERSIZE)
bytes of sense data is being copied to sense_buffer.

Correct sense_data_length(<= 18 bytes), from a UFS device will not
cause any problem. If a UFS device returns wrong sense_data_length
( > 18 bytes), then the wrong sense data will be copied to
sense_buffer.

Signed-off-by: Santosh Y <santoshsy@xxxxxxxxx>
Reviewed-by: Vinayak Holikatti <vinholikatti@xxxxxxxxx>
---
 drivers/scsi/ufs/ufs.h    |    1 +
 drivers/scsi/ufs/ufshcd.c |    2 +-
 2 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h
index b207529..0af1aac 100644
--- a/drivers/scsi/ufs/ufs.h
+++ b/drivers/scsi/ufs/ufs.h
@@ -47,6 +47,7 @@
 #define _UFS_H
 
 #define MAX_CDB_SIZE	16
+#define MAX_SENSE_SIZE	18
 
 #define UPIU_HEADER_DWORD(byte3, byte2, byte1, byte0)\
 			((byte3 << 24) | (byte2 << 16) |\
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 3e4e102..662d00f 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -479,7 +479,7 @@ static inline void ufshcd_copy_sense_data(struct ufshcd_lrb *lrbp)
 		len = be16_to_cpu(lrbp->ucd_rsp_ptr->sense_data_len);
 		memcpy(lrbp->sense_buffer,
 			lrbp->ucd_rsp_ptr->sense_data,
-			min_t(int, len, SCSI_SENSE_BUFFERSIZE));
+			min_t(int, len, MAX_SENSE_SIZE));
 	}
 }
 
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux