[PATCH 11/14] drm/amd/display: Guard Possible Null Pointer Dereference
Zaeem Mohamed
zaeem.mohamed at amd.com
Tue Jan 21 19:39:16 UTC 2025
From: Sung Lee <Sung.Lee at amd.com>
[WHY]
In some situations, dc->res_pool may be null.
[HOW]
Check if pointer is null before dereference.
Reviewed-by: Joshua Aberback <joshua.aberback at amd.com>
Signed-off-by: Sung Lee <Sung.Lee at amd.com>
Signed-off-by: Zaeem Mohamed <zaeem.mohamed at amd.com>
---
drivers/gpu/drm/amd/display/dc/core/dc.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
index a8b0d558b132..3ebbb59a22e3 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -5553,9 +5553,11 @@ void dc_allow_idle_optimizations_internal(struct dc *dc, bool allow, char const
if (dc->clk_mgr != NULL && dc->clk_mgr->funcs->get_hard_min_memclk)
idle_dramclk_khz = dc->clk_mgr->funcs->get_hard_min_memclk(dc->clk_mgr);
- for (i = 0; i < dc->res_pool->pipe_count; i++) {
- pipe = &context->res_ctx.pipe_ctx[i];
- subvp_pipe_type[i] = dc_state_get_pipe_subvp_type(context, pipe);
+ if (dc->res_pool && context) {
+ for (i = 0; i < dc->res_pool->pipe_count; i++) {
+ pipe = &context->res_ctx.pipe_ctx[i];
+ subvp_pipe_type[i] = dc_state_get_pipe_subvp_type(context, pipe);
+ }
}
DC_LOG_DC("%s: allow_idle=%d\n HardMinUClk_Khz=%d HardMinDramclk_Khz=%d\n Pipe_0=%d Pipe_1=%d Pipe_2=%d Pipe_3=%d Pipe_4=%d Pipe_5=%d (caller=%s)\n",
--
2.34.1
More information about the amd-gfx
mailing list