]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/amd/display: add null check
authorPeichen Huang <PeiChen.Huang@amd.com>
Thu, 12 Jun 2025 08:06:41 +0000 (16:06 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Aug 2025 16:41:14 +0000 (18:41 +0200)
[ 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

index 3dd7e2b6d5300c43c8d56e3c3927dcec18102dfa..943ebd5c79e3e36a34d9d2b22f99c885216fded0 100644 (file)
@@ -6394,11 +6394,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;