Skip to content

Commit

Permalink
scsi: ufs: Fix potential NULL pointer access during memcpy
Browse files Browse the repository at this point in the history
If param_offset is not 0, the memcpy length shouldn't be the true
descriptor length.

Link: https://lore.kernel.org/r/20200603091959.27618-4-huobean@gmail.com
Acked-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
  • Loading branch information
beanhuo authored and martinkpetersen committed Jun 16, 2020
1 parent c4607a0 commit cbe193f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/scsi/ufs/ufshcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3223,8 +3223,8 @@ int ufshcd_read_desc_param(struct ufs_hba *hba,
}

/* Check wherher we will not copy more data, than available */
if (is_kmalloc && param_size > buff_len)
param_size = buff_len;
if (is_kmalloc && (param_offset + param_size) > buff_len)
param_size = buff_len - param_offset;

if (is_kmalloc)
memcpy(param_read_buf, &desc_buf[param_offset], param_size);
Expand Down

0 comments on commit cbe193f

Please sign in to comment.