]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
scsi: ufs: Use data structure size in pointer arithmetic
authorAvri Altman <avri.altman@wdc.com>
Sun, 7 Oct 2018 14:30:36 +0000 (17:30 +0300)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 11 Oct 2018 03:09:46 +0000 (23:09 -0400)
Use the structure size in pointer arithmetic instead of an opaque 32
bytes for the over-allocation of descriptors.

Signed-off-by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/ufs/ufs.h
drivers/scsi/ufs/ufshcd.c

index f1d77dc2a1aff66494c3baa8c8f39267ae60342c..f5800c3203b005f6a1891cf390a9e3dfd0fec5ee 100644 (file)
@@ -40,7 +40,7 @@
 #include <linux/types.h>
 #include <uapi/scsi/scsi_bsg_ufs.h>
 
-#define GENERAL_UPIU_REQUEST_SIZE 32
+#define GENERAL_UPIU_REQUEST_SIZE (sizeof(struct utp_upiu_req))
 #define QUERY_DESC_MAX_SIZE       255
 #define QUERY_DESC_MIN_SIZE       2
 #define QUERY_DESC_HDR_SIZE       2
index 69d023788e147e28a7d719951b22ca77e53af5ff..cc48518e9639943e000e2a54ec94404e977d1d38 100644 (file)
@@ -2262,7 +2262,6 @@ static void ufshcd_prepare_utp_query_req_upiu(struct ufs_hba *hba,
        struct utp_upiu_req *ucd_req_ptr = lrbp->ucd_req_ptr;
        struct ufs_query *query = &hba->dev_cmd.query;
        u16 len = be16_to_cpu(query->request.upiu_req.length);
-       u8 *descp = (u8 *)lrbp->ucd_req_ptr + GENERAL_UPIU_REQUEST_SIZE;
 
        /* Query request header */
        ucd_req_ptr->header.dword_0 = UPIU_HEADER_DWORD(
@@ -2284,7 +2283,7 @@ static void ufshcd_prepare_utp_query_req_upiu(struct ufs_hba *hba,
 
        /* Copy the Descriptor */
        if (query->request.upiu_req.opcode == UPIU_QUERY_OPCODE_WRITE_DESC)
-               memcpy(descp, query->descriptor, len);
+               memcpy(ucd_req_ptr + 1, query->descriptor, len);
 
        memset(lrbp->ucd_rsp_ptr, 0, sizeof(struct utp_upiu_rsp));
 }