This patch is similar to commit 66951d98d9bf("drm/amd/display: 
 Add NULL test for 'timing generator' in 'dcn21_set_pipe()'").

In "u32 otg_inst = pipe_ctx->stream_res.tg->inst;"
pipe_ctx->stream_res.tg could be NULL, it is relying on the caller to
ensure the tg is not NULL.

So the dcn21_set_abm_immediate_disable function should also add NULL test
for 'timing generator'.

Signed-off-by: Chen Yufeng <[email protected]>
---
 drivers/gpu/drm/amd/display/dc/hwss/dcn21/dcn21_hwseq.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/hwss/dcn21/dcn21_hwseq.c 
b/drivers/gpu/drm/amd/display/dc/hwss/dcn21/dcn21_hwseq.c
index 61efb15572ff..50896aed8245 100644
--- a/drivers/gpu/drm/amd/display/dc/hwss/dcn21/dcn21_hwseq.c
+++ b/drivers/gpu/drm/amd/display/dc/hwss/dcn21/dcn21_hwseq.c
@@ -179,9 +179,15 @@ static void dmub_abm_set_backlight(struct dc_context *dc, 
uint32_t backlight_pwm
 void dcn21_set_abm_immediate_disable(struct pipe_ctx *pipe_ctx)
 {
        struct abm *abm = pipe_ctx->stream_res.abm;
-       uint32_t otg_inst = pipe_ctx->stream_res.tg->inst;
+       struct timing_generator *tg = pipe_ctx->stream_res.tg;
        struct panel_cntl *panel_cntl = pipe_ctx->stream->link->panel_cntl;
        struct dmcu *dmcu = pipe_ctx->stream->ctx->dc->res_pool->dmcu;
+       uint32_t otg_inst;
+
+       if (!abm || !tg || !panel_cntl)
+               return;
+
+       otg_inst = tg->inst;
 
        // make a short term w/a for an issue that backlight ramping 
unexpectedly paused in the middle,
        // will decouple backlight from ABM and redefine DMUB interface, then 
this w/a could be removed
-- 
2.34.1

Reply via email to