diff options
author | Srinivasan Shanmugam <srinivasan.shanmugam@amd.com> | 2024-12-12 12:33:29 +0300 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2024-12-18 20:39:08 +0300 |
commit | b64f2f3e870d324703246757cb67cec09a64a1c9 (patch) | |
tree | fe9e294a2be5e339119eddeb2c36231e4de86631 /drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | |
parent | e37ccf44ace3f58fc9d84de1acd439077b9f7fef (diff) | |
download | linux-b64f2f3e870d324703246757cb67cec09a64a1c9.tar.xz |
drm/amd/display: Fix NULL pointer dereference in dmub_tracebuffer_show
It corrects the issue by checking if 'adev->dm.dmub_srv' is NULL before
accessing its 'meta_info' member. This ensures that we do not
dereference a NULL pointer.
Fixes the below:
drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_debugfs.c:917 dmub_tracebuffer_show()
warn: address of 'adev->dm.dmub_srv->meta_info' is non-NULL
drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_debugfs.c
901 static int dmub_tracebuffer_show(struct seq_file *m, void *data)
902 {
903 struct amdgpu_device *adev = m->private;
904 struct dmub_srv_fb_info *fb_info = adev->dm.dmub_fb_info;
905 struct dmub_fw_meta_info *fw_meta_info = &adev->dm.dmub_srv->meta_info;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Even if adev->dm.dmub_srv is NULL, the address of ->meta_info can't be NULL
906 struct dmub_debugfs_trace_entry *entries;
907 uint8_t *tbuf_base;
908 uint32_t tbuf_size, max_entries, num_entries, first_entry, i;
909
910 if (!fb_info)
911 return 0;
912
913 tbuf_base = (uint8_t *)fb_info->fb[DMUB_WINDOW_5_TRACEBUFF].cpu_addr;
914 if (!tbuf_base)
915 return 0;
916
--> 917 tbuf_size = fw_meta_info ? fw_meta_info->trace_buffer_size :
^^^^^^^^^^^^ Always non-NULL
918 DMUB_TRACE_BUFFER_SIZE;
919 max_entries = (tbuf_size - sizeof(struct dmub_debugfs_trace_header)) /
920 sizeof(struct dmub_debugfs_trace_entry);
921
922 num_entries =
v2: Initialize struct dmub_fw_meta_info *fw_meta_info to NULL (Dan Carpenter)
Fixes: 5a498172c8d0 ("drm/amd/display: Make DMCUB tracebuffer debugfs chronological")
Cc: Leo Li <sunpeng.li@amd.com>
Cc: Tom Chung <chiahsuan.chung@amd.com>
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Cc: Roman Li <roman.li@amd.com>
Cc: Alex Hung <alex.hung@amd.com>
Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Hamza Mahfooz <hamza.mahfooz@amd.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Reviewed-by: Roman Li <roman.li@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c')
0 files changed, 0 insertions, 0 deletions