drm/amd/display: Fix a potential buffer overflow in 'dp_dsc_clock_en_read()'
authorSrinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Tue, 23 Jan 2024 14:48:07 +0000 (20:18 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 25 Jan 2024 19:58:02 +0000 (14:58 -0500)
Tell snprintf() to store at most 10 bytes in the output buffer
instead of 30.

Fixes the below:
drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_debugfs.c:1508 dp_dsc_clock_en_read() error: snprintf() is printing too much 30 vs 10

Fixes: c06e09b76639 ("drm/amd/display: Add DSC parameters logging to debugfs")
Cc: Alex Hung <alex.hung@amd.com>
Cc: Qingqing Zhuo <qingqing.zhuo@amd.com>
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c

index 68a846323912768edea6c6d330a3491c3aff1b27..85fc6181303bb5ddd4f41441fa201922119cd642 100644 (file)
@@ -1483,7 +1483,7 @@ static ssize_t dp_dsc_clock_en_read(struct file *f, char __user *buf,
        const uint32_t rd_buf_size = 10;
        struct pipe_ctx *pipe_ctx;
        ssize_t result = 0;
-       int i, r, str_len = 30;
+       int i, r, str_len = 10;
 
        rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);