[bug report] drm/amd/display: define link res and make it accessible to all link interfaces
Dan Carpenter
dan.carpenter at oracle.com
Mon Jan 10 15:30:33 UTC 2022
Hello Wenjing Liu,
The patch ef30f441f6ac: "drm/amd/display: define link res and make it
accessible to all link interfaces" from Nov 25, 2021, leads to the
following Smatch static checker warning:
drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_link.c:4586 dc_link_set_drive_settings()
warn: address of 'dc->current_state->res_ctx.pipe_ctx[i]' is non-NULL
drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_link.c:4587 dc_link_set_drive_settings()
error: we previously assumed 'pipe->stream' could be null (see line 4581)
drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_link.c
4568 void dc_link_set_drive_settings(struct dc *dc,
4569 struct link_training_settings *lt_settings,
4570 const struct dc_link *link)
4571 {
4572
4573 int i;
4574 struct pipe_ctx *pipe = NULL;
4575 const struct link_resource *link_res;
4576
4577 link_res = dc_link_get_cur_link_res(link);
4578
4579 for (i = 0; i < MAX_PIPES; i++) {
4580 pipe = &dc->current_state->res_ctx.pipe_ctx[i];
4581 if (pipe->stream && pipe->stream->link) {
^^^^^^^^^^^^
This checks for "pipe->stream"
4582 if (pipe->stream->link == link)
4583 break;
4584 }
4585 }
4586 if (pipe && link_res)
"pipe" can't possibly be NULL
--> 4587 dc_link_dp_set_drive_settings(pipe->stream->link, link_res, lt_settings);
This dereferences "pipe->stream" without checking
4588 else
4589 ASSERT_CRITICAL(false);
4590 }
regards,
dan carpenter
More information about the amd-gfx
mailing list