Commit cbe193f6 authored by Bean Huo's avatar Bean Huo Committed by Martin K. Petersen

scsi: ufs: Fix potential NULL pointer access during memcpy

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.comAcked-by: default avatarAvri Altman <avri.altman@wdc.com>
Signed-off-by: default avatarBean Huo <beanhuo@micron.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent c4607a09
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment