disp: msm: add check for buffer length before copy

Length of the buffer to be copied is checked
against both source and destination buffer lengths
before copying. This ensures that there is  no
buffer overflow while reading as well as writing.

Change-Id: I4bd1a5892b47771aef4c23a4d1594fc1c8361577
Signed-off-by: Satya Rama Aditya Pinapala <psraditya30@codeaurora.org>
Šī revīzija ir iekļauta:
Satya Rama Aditya Pinapala
2019-10-21 13:47:52 -07:00
vecāks ca2fbfd531
revīzija be08b4e451
3 mainīti faili ar 17 papildinājumiem un 3 dzēšanām

Parādīt failu

@@ -1731,7 +1731,10 @@ static ssize_t _sde_debugfs_conn_cmd_tx_sts_read(struct file *file,
return 0;
}
blen = min_t(size_t, MAX_CMD_PAYLOAD_SIZE, count);
if (blen > count)
blen = count;
blen = min_t(size_t, blen, MAX_CMD_PAYLOAD_SIZE);
if (copy_to_user(buf, buffer, blen)) {
SDE_ERROR("copy to user buffer failed\n");
return -EFAULT;