Commit 158b9201 authored by Peichen Huang's avatar Peichen Huang Committed by Alex Deucher
Browse files

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: default avatarCruise Hung <cruise.hung@amd.com>
Signed-off-by: default avatarPeichen Huang <PeiChen.Huang@amd.com>
Signed-off-by: default avatarRay Wu <ray.wu@amd.com>
Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 38b20968
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -6398,11 +6398,13 @@ unsigned int dc_get_det_buffer_size_from_state(const struct dc_state *context)
 */
bool dc_get_host_router_index(const struct dc_link *link, unsigned int *host_router_index)
{
	struct dc *dc = link->ctx->dc;
	struct dc *dc;

	if (link->ep_type != DISPLAY_ENDPOINT_USB4_DPIA)
	if (!link || !host_router_index || link->ep_type != DISPLAY_ENDPOINT_USB4_DPIA)
		return false;

	dc = link->ctx->dc;

	if (link->link_index < dc->lowest_dpia_link_index)
		return false;