From: Alex Hung <alex.hung@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: Harry Wentland <harry.wentland@amd.com>,
Leo Li <sunpeng.li@amd.com>,
Aurabindo Pillai <aurabindo.pillai@amd.com>,
Roman Li <roman.li@amd.com>, Wayne Lin <wayne.lin@amd.com>,
Tom Chung <chiahsuan.chung@amd.com>,
"Fangzhi Zuo" <jerry.zuo@amd.com>,
Dan Wheeler <daniel.wheeler@amd.com>, Ray Wu <Ray.Wu@amd.com>,
Ivan Lipski <ivan.lipski@amd.com>, Alex Hung <alex.hung@amd.com>,
Gaghik Khachatrian <gaghik.khachatrian@amd.com>,
"Dillon Varone" <dillon.varone@amd.com>
Subject: [PATCH 01/21] drm/amd/display: Clean up NULL pointer warnings in dml2
Date: Thu, 5 Mar 2026 20:13:27 -0700 [thread overview]
Message-ID: <20260306031932.136179-2-alex.hung@amd.com> (raw)
In-Reply-To: <20260306031932.136179-1-alex.hung@amd.com>
From: Gaghik Khachatrian <gaghik.khachatrian@amd.com>
This commit addresses multiple warnings by adding defensive
checks for NULL pointers before dereferencing them. The changes ensure
that pointers such as are validated, preventing potential undefined
behavior.
Reviewed-by: Dillon Varone <dillon.varone@amd.com>
Signed-off-by: Gaghik Khachatrian <gaghik.khachatrian@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
---
.../amd/display/dc/dml2_0/dml2_mall_phantom.c | 41 +++++++++++++++++--
1 file changed, 38 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/dml2_0/dml2_mall_phantom.c b/drivers/gpu/drm/amd/display/dc/dml2_0/dml2_mall_phantom.c
index 66040c877d68..d56e58ce26c7 100644
--- a/drivers/gpu/drm/amd/display/dc/dml2_0/dml2_mall_phantom.c
+++ b/drivers/gpu/drm/amd/display/dc/dml2_0/dml2_mall_phantom.c
@@ -357,7 +357,7 @@ static bool enough_pipes_for_subvp(struct dml2_context *ctx, struct dc_state *st
*/
static bool subvp_subvp_schedulable(struct dml2_context *ctx, struct dc_state *context)
{
- struct pipe_ctx *subvp_pipes[2];
+ struct pipe_ctx *subvp_pipes[2] = { NULL, NULL };
struct dc_stream_state *phantom = NULL;
uint32_t microschedule_lines = 0;
uint32_t index = 0;
@@ -369,6 +369,9 @@ static bool subvp_subvp_schedulable(struct dml2_context *ctx, struct dc_state *c
struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
uint32_t time_us = 0;
+ if (pipe == NULL || pipe->stream == NULL)
+ continue;
+
/* Loop to calculate the maximum microschedule time between the two SubVP pipes,
* and also to store the two main SubVP pipe pointers in subvp_pipes[2].
*/
@@ -386,14 +389,19 @@ static bool subvp_subvp_schedulable(struct dml2_context *ctx, struct dc_state *c
if (time_us > max_microschedule_us)
max_microschedule_us = time_us;
- subvp_pipes[index] = pipe;
- index++;
+ if (index < 2)
+ subvp_pipes[index++] = pipe;
// Maximum 2 SubVP pipes
if (index == 2)
break;
}
}
+
+ /* Minimal guard to avoid C6001 before subvp_pipes[0]/[1] dereference */
+ if (index < 2 || !subvp_pipes[0] || !subvp_pipes[1])
+ return false;
+
vactive1_us = ((subvp_pipes[0]->stream->timing.v_addressable * subvp_pipes[0]->stream->timing.h_total) /
(double)(subvp_pipes[0]->stream->timing.pix_clk_100hz * 100)) * 1000000;
vactive2_us = ((subvp_pipes[1]->stream->timing.v_addressable * subvp_pipes[1]->stream->timing.h_total) /
@@ -459,6 +467,11 @@ bool dml2_svp_drr_schedulable(struct dml2_context *ctx, struct dc_state *context
break;
}
+ if (pipe == NULL || pipe->stream == NULL) {
+ // Defensive: should never happen, try to catch in debug
+ ASSERT(0);
+ return false;
+ }
phantom_stream = ctx->config.svp_pstate.callbacks.get_paired_subvp_stream(context, pipe->stream);
main_timing = &pipe->stream->timing;
phantom_timing = &phantom_stream->timing;
@@ -549,6 +562,13 @@ static bool subvp_vblank_schedulable(struct dml2_context *ctx, struct dc_state *
if (!subvp_pipe && pipe_mall_type == SUBVP_MAIN)
subvp_pipe = pipe;
}
+
+ if (subvp_pipe == NULL) {
+ // Defensive: should never happen, catch in debug
+ ASSERT(0);
+ return false;
+ }
+
// Use ignore_msa_timing_param flag to identify as DRR
if (found && context->res_ctx.pipe_ctx[vblank_index].stream->ignore_msa_timing_param) {
// SUBVP + DRR case
@@ -753,6 +773,12 @@ static void enable_phantom_plane(struct dml2_context *ctx,
return;
}
+ /* Minimal NULL guard for C6011 */
+ if (!phantom_plane) {
+ ASSERT(0);
+ continue;
+ }
+
memcpy(&phantom_plane->address, &curr_pipe->plane_state->address, sizeof(phantom_plane->address));
memcpy(&phantom_plane->scaling_quality, &curr_pipe->plane_state->scaling_quality,
sizeof(phantom_plane->scaling_quality));
@@ -880,6 +906,11 @@ bool dml2_svp_add_phantom_pipe_to_dc_state(struct dml2_context *ctx, struct dc_s
if (ctx->config.svp_pstate.force_disable_subvp)
return false;
+ if (!state) {
+ ASSERT(0);
+ return false;
+ }
+
if (!all_pipes_have_stream_and_plane(ctx, state))
return false;
@@ -898,6 +929,10 @@ bool dml2_svp_add_phantom_pipe_to_dc_state(struct dml2_context *ctx, struct dc_s
}
if (enough_pipes_for_subvp(ctx, state) && assign_subvp_pipe(ctx, state, &dc_pipe_idx)) {
+ if (state->res_ctx.pipe_ctx[dc_pipe_idx].stream == NULL) {
+ ASSERT(0);
+ return false;
+ }
dml_pipe_idx = dml2_helper_find_dml_pipe_idx_by_stream_id(ctx, state->res_ctx.pipe_ctx[dc_pipe_idx].stream->stream_id);
svp_height = mode_support_info->SubViewportLinesNeededInMALL[dml_pipe_idx];
vstartup = dml_get_vstartup_calculated(&ctx->v20.dml_core_ctx, dml_pipe_idx);
--
2.43.0
next prev parent reply other threads:[~2026-03-06 3:24 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-06 3:13 [PATCH 00/21] DC Patches March 05, 2026 Alex Hung
2026-03-06 3:13 ` Alex Hung [this message]
2026-03-06 3:13 ` [PATCH 02/21] drm/amd/display: Return early from vesa replay enable function Alex Hung
2026-03-06 3:13 ` [PATCH 03/21] drm/amd/display: Add min clock init for DML21 mode programming Alex Hung
2026-03-06 3:13 ` [PATCH 04/21] drm/amd/display: Set chroma taps to 1 if luma taps are 1 Alex Hung
2026-03-09 20:47 ` Melissa Wen
2026-03-06 3:13 ` [PATCH 05/21] drm/amd/display: Add NV12/P010 formats to primary plane Alex Hung
2026-03-06 3:13 ` [PATCH 06/21] drm/amd/display: Add COLOR_ENCODING/COLOR_RANGE to overlay planes Alex Hung
2026-03-06 3:13 ` [PATCH 07/21] drm/amd/display: Update underflow detection Alex Hung
2026-03-06 3:13 ` [PATCH 08/21] drm/amd/display: Add ESD detection for replay recovery Alex Hung
2026-03-06 3:13 ` [PATCH 09/21] drm/amd/display: Add missing DCCG register entries for DCN20-DCN316 Alex Hung
2026-03-06 3:13 ` [PATCH 10/21] drm/amd/display: Fix HWSS v3 fast path determination Alex Hung
2026-03-06 3:13 ` [PATCH 11/21] drm/amd/display: Add new types to replay config Alex Hung
2026-03-06 3:13 ` [PATCH 12/21] drm/amd/display: Add documentation and cleanup DMUB HW lock manager Alex Hung
2026-03-06 3:13 ` [PATCH 13/21] drm/amd/display: Check for S0i3 to be done before DCCG init on DCN21 Alex Hung
2026-03-06 3:13 ` [PATCH 14/21] drm/amd/display: Fix compile warnings in dml2_0 Alex Hung
2026-03-06 3:13 ` [PATCH 15/21] drm/amd/display: Add back missing memory type in array Alex Hung
2026-03-06 3:13 ` [PATCH 16/21] drm/amd/display: Clean up unused code Alex Hung
2026-03-06 3:13 ` [PATCH 17/21] drm/amd/display: Enable dcn42 DC clk_mgr Alex Hung
2026-03-06 3:13 ` [PATCH 18/21] drm/amd/display: Add DML support for dcn42 Alex Hung
2026-03-06 3:13 ` [PATCH 19/21] drm/amd/display: Sync dcn42 with DC 3.2.373 Alex Hung
2026-04-13 13:09 ` DC analog support regressed by "drm/amd/display: Sync dcn42 with DC 3.2.373" Timur Kristóf
2026-04-15 18:23 ` Li, Roman
2026-03-06 3:13 ` [PATCH 20/21] drm/amd/display: [FW Promotion] Release 0.1.50.0 Alex Hung
2026-03-06 3:13 ` [PATCH 21/21] drm/amd/display: Promote DC to 3.2.373 Alex Hung
2026-03-09 13:03 ` [PATCH 00/21] DC Patches March 05, 2026 Wheeler, Daniel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260306031932.136179-2-alex.hung@amd.com \
--to=alex.hung@amd.com \
--cc=Ray.Wu@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=aurabindo.pillai@amd.com \
--cc=chiahsuan.chung@amd.com \
--cc=daniel.wheeler@amd.com \
--cc=dillon.varone@amd.com \
--cc=gaghik.khachatrian@amd.com \
--cc=harry.wentland@amd.com \
--cc=ivan.lipski@amd.com \
--cc=jerry.zuo@amd.com \
--cc=roman.li@amd.com \
--cc=sunpeng.li@amd.com \
--cc=wayne.lin@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox