Skip to content

Commit 158b920

Browse files
Peichen Huangalexdeucher
authored andcommitted
drm/amd/display: add null check
[WHY] Prevents null pointer dereferences to enhance function robustness [HOW] Adds early null check and return false if invalid. Reviewed-by: Cruise Hung <cruise.hung@amd.com> Signed-off-by: Peichen Huang <PeiChen.Huang@amd.com> Signed-off-by: Ray Wu <ray.wu@amd.com> Tested-by: Daniel Wheeler <daniel.wheeler@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 38b2096 commit 158b920

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • drivers/gpu/drm/amd/display/dc/core

drivers/gpu/drm/amd/display/dc/core/dc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6398,11 +6398,13 @@ unsigned int dc_get_det_buffer_size_from_state(const struct dc_state *context)
63986398
*/
63996399
bool dc_get_host_router_index(const struct dc_link *link, unsigned int *host_router_index)
64006400
{
6401-
struct dc *dc = link->ctx->dc;
6401+
struct dc *dc;
64026402

6403-
if (link->ep_type != DISPLAY_ENDPOINT_USB4_DPIA)
6403+
if (!link || !host_router_index || link->ep_type != DISPLAY_ENDPOINT_USB4_DPIA)
64046404
return false;
64056405

6406+
dc = link->ctx->dc;
6407+
64066408
if (link->link_index < dc->lowest_dpia_link_index)
64076409
return false;
64086410

0 commit comments

Comments
 (0)