drm/amd/display: Check link_res->hpo_dp_link_enc before using it

commit 0beca868cd 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>
This commit is contained in:
Alex Hung 2024-06-27 16:45:39 -06:00 committed by Greg Kroah-Hartman
parent 73697928c8
commit 8c22a62288

View 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 {