In link_set_dsc_pps_packet(), 'struct display_stream_compressor *dsc'
was dereferenced in a DC_LOGGER_INIT(dsc->ctx->logger); before the 'dsc'
NULL pointer check.

Fixes the below:
drivers/gpu/drm/amd/amdgpu/../display/dc/link/link_dpms.c:905 
link_set_dsc_pps_packet() warn: variable dereferenced before check 'dsc' (see 
line 903)

Cc: sta...@vger.kernel.org
Cc: Aurabindo Pillai <aurabindo.pil...@amd.com>
Cc: Rodrigo Siqueira <rodrigo.sique...@amd.com>
Cc: Hamza Mahfooz <hamza.mahf...@amd.com>
Cc: Wenjing Liu <wenjing....@amd.com>
Cc: Qingqing Zhuo <qingqing.z...@amd.com>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmu...@amd.com>
---
 drivers/gpu/drm/amd/display/dc/link/link_dpms.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/link/link_dpms.c 
b/drivers/gpu/drm/amd/display/dc/link/link_dpms.c
index 3de148004c06..562eb79bfbc8 100644
--- a/drivers/gpu/drm/amd/display/dc/link/link_dpms.c
+++ b/drivers/gpu/drm/amd/display/dc/link/link_dpms.c
@@ -900,11 +900,12 @@ bool link_set_dsc_pps_packet(struct pipe_ctx *pipe_ctx, 
bool enable, bool immedi
 {
        struct display_stream_compressor *dsc = pipe_ctx->stream_res.dsc;
        struct dc_stream_state *stream = pipe_ctx->stream;
-       DC_LOGGER_INIT(dsc->ctx->logger);
 
        if (!pipe_ctx->stream->timing.flags.DSC || !dsc)
                return false;
 
+       DC_LOGGER_INIT(dsc->ctx->logger);
+
        if (enable) {
                struct dsc_config dsc_cfg;
                uint8_t dsc_packed_pps[128];
-- 
2.34.1

Reply via email to