From 804f6e0de2f7f171d0c704ddff93856ca34fb619 Mon Sep 17 00:00:00 2001 From: Satya Rama Aditya Pinapala Date: Fri, 19 Jul 2019 16:07:23 -0700 Subject: [PATCH] disp: msm: dsi: add check before buffer copy This change adds a check for the length of the buffer before copying it to avoid a buffer overflow. Change-Id: I146895660be4060d9896706636257a57c6aef94f Signed-off-by: Satya Rama Aditya Pinapala --- msm/dsi/dsi_ctrl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/msm/dsi/dsi_ctrl.c b/msm/dsi/dsi_ctrl.c index 84133ebc35f0..9509e1e1eddf 100644 --- a/msm/dsi/dsi_ctrl.c +++ b/msm/dsi/dsi_ctrl.c @@ -116,7 +116,7 @@ static ssize_t debugfs_state_info_read(struct file *file, dsi_ctrl->clk_freq.pix_clk_rate, dsi_ctrl->clk_freq.esc_clk_rate); - /* TODO: make sure that this does not exceed 4K */ + len = min_t(size_t, len, SZ_4K); if (copy_to_user(buff, buf, len)) { kfree(buf); return -EFAULT; @@ -172,7 +172,7 @@ static ssize_t debugfs_reg_dump_read(struct file *file, } - /* TODO: make sure that this does not exceed 4K */ + len = min_t(size_t, len, SZ_4K); if (copy_to_user(buff, buf, len)) { kfree(buf); return -EFAULT;