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>
This commit is contained in:
Satya Rama Aditya Pinapala
2019-10-21 13:47:52 -07:00
parent ca2fbfd531
commit be08b4e451
3 changed files with 17 additions and 3 deletions

View File

@@ -116,6 +116,9 @@ static ssize_t debugfs_state_info_read(struct file *file,
dsi_ctrl->clk_freq.pix_clk_rate,
dsi_ctrl->clk_freq.esc_clk_rate);
if (len > count)
len = count;
len = min_t(size_t, len, SZ_4K);
if (copy_to_user(buff, buf, len)) {
kfree(buf);
@@ -171,6 +174,8 @@ static ssize_t debugfs_reg_dump_read(struct file *file,
return rc;
}
if (len > count)
len = count;
len = min_t(size_t, len, SZ_4K);
if (copy_to_user(buff, buf, len)) {