On 2/13/2024 12:07 AM, Kees Cook wrote:
On Thu, Feb 01, 2024 at 03:28:45PM +0530, Srinivasan Shanmugam wrote:
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.

Fixes: 474ac4a875ca ("drm/amd/display: Implement some asic specific abm call 
backs.")
Cc: Yongqiang Sun <yongqiang....@amd.com>
Cc: Anthony Koo <anthony....@amd.com>
Cc: Rodrigo Siqueira <rodrigo.sique...@amd.com>
Cc: Aurabindo Pillai <aurabindo.pil...@amd.com>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmu...@amd.com>
---
v2:
   - s/u32/uint32_t for consistency (Anthony)

  .../amd/display/dc/hwss/dcn21/dcn21_hwseq.c   | 24 +++++++++++--------
  1 file changed, 14 insertions(+), 10 deletions(-)

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 8e88dcaf88f5..8323077bba15 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
@@ -206,28 +206,32 @@ void dcn21_set_abm_immediate_disable(struct pipe_ctx 
*pipe_ctx)
  void dcn21_set_pipe(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;
Is the "if" supposed to be using "||"s instead of "&&"s? I noticed
Coverity complained "tg may be NULL" for the "tg->inst" dereference...

-Kees

Thanks Kees!

It is fixed in the below commit:

commit ccc1e78470efb6572a71ba88d70995e8eee2f6e5
Author: Dan Carpenter <dan.carpen...@linaro.org>
Date:   Fri Feb 9 16:02:42 2024 +0300

    drm/amd/display: Fix && vs || typos

    These ANDs should be ORs or it will lead to a NULL dereference.

    Fixes: fb5a3d037082 ("drm/amd/display: Add NULL test for 'timing generator' in 'dcn21_set_pipe()'")     Fixes: 886571d217d7 ("drm/amd/display: Fix 'panel_cntl' could be null in 'dcn21_set_backlight_level()'")
    Reviewed-by: Anthony Koo <anthony....@amd.com>
    Signed-off-by: Dan Carpenter <dan.carpen...@linaro.org>
    Signed-off-by: Hamza Mahfooz <hamza.mahf...@amd.com>

-Srini

Reply via email to