6.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peichen Huang PeiChen.Huang@amd.com
[ Upstream commit 158b9201c17fc93ed4253c2f03b77fd2671669a1 ]
[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 Signed-off-by: Sasha Levin sashal@kernel.org --- drivers/gpu/drm/amd/display/dc/core/dc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c index d6f0c82d8dda..ff94ceea2218 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c @@ -6265,11 +6265,13 @@ struct dc_power_profile dc_get_power_profile_for_dc_state(const struct dc_state */ 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;