]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/amd/display: Check link_res->hpo_dp_link_enc before using it
authorAlex Hung <alex.hung@amd.com>
Thu, 27 Jun 2024 22:45:39 +0000 (16:45 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 9 Sep 2025 16:54:21 +0000 (18:54 +0200)
commit 0beca868cde8742240cd0038141c30482d2b7eb8 upstream.

[WHAT & HOW]
Functions dp_enable_link_phy and dp_disable_link_phy can pass link_res
without initializing hpo_dp_link_enc and it is necessary to check for
null before dereferencing.

This fixes 2 FORWARD_NULL issues reported by Coverity.

Reviewed-by: Rodrigo Siqueira <rodrigo.siqueira@amd.com>
Signed-off-by: Jerry Zuo <jerry.zuo@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
[ Minor context change fixed. ]
Signed-off-by: Alva Lan <alvalan9@foxmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/amd/display/dc/link/link_hwss_hpo_dp.c

index 153a88381f2c76571f85d95e9a32ace94682ca96..fd9809b17882ab712d87d35bbea9c3b642f0f747 100644 (file)
@@ -29,6 +29,8 @@
 #include "dc_link_dp.h"
 #include "clk_mgr.h"
 
+#define DC_LOGGER link->ctx->logger
+
 static enum phyd32clk_clock_source get_phyd32clk_src(struct dc_link *link)
 {
        switch (link->link_enc->transmitter) {
@@ -224,6 +226,11 @@ static void disable_hpo_dp_link_output(struct dc_link *link,
                const struct link_resource *link_res,
                enum signal_type signal)
 {
+       if (!link_res->hpo_dp_link_enc) {
+               DC_LOG_ERROR("%s: invalid hpo_dp_link_enc\n", __func__);
+               return;
+       }
+
        if (IS_FPGA_MAXIMUS_DC(link->dc->ctx->dce_environment)) {
                disable_hpo_dp_fpga_link_output(link, link_res, signal);
        } else {