[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240925115823.1303019-117-sashal@kernel.org>
Date: Wed, 25 Sep 2024 07:52:16 -0400
From: Sasha Levin <sashal@...nel.org>
To: linux-kernel@...r.kernel.org,
stable@...r.kernel.org
Cc: Srinivasan Shanmugam <srinivasan.shanmugam@....com>,
Tom Chung <chiahsuan.chung@....com>,
Rodrigo Siqueira <Rodrigo.Siqueira@....com>,
Roman Li <roman.li@....com>,
Alex Hung <alex.hung@....com>,
Aurabindo Pillai <aurabindo.pillai@....com>,
Harry Wentland <harry.wentland@....com>,
Hamza Mahfooz <hamza.mahfooz@....com>,
Alex Deucher <alexander.deucher@....com>,
Sasha Levin <sashal@...nel.org>,
sunpeng.li@....com,
christian.koenig@....com,
Xinhui.Pan@....com,
airlied@...il.com,
daniel@...ll.ch,
moadhuri@....com,
amd-gfx@...ts.freedesktop.org,
dri-devel@...ts.freedesktop.org
Subject: [PATCH AUTOSEL 6.10 117/197] drm/amd/display: Add null check for head_pipe in dcn201_acquire_free_pipe_for_layer
From: Srinivasan Shanmugam <srinivasan.shanmugam@....com>
[ Upstream commit f22f4754aaa47d8c59f166ba3042182859e5dff7 ]
This commit addresses a potential null pointer dereference issue in the
`dcn201_acquire_free_pipe_for_layer` function. The issue could occur
when `head_pipe` is null.
The fix adds a check to ensure `head_pipe` is not null before asserting
it. If `head_pipe` is null, the function returns NULL to prevent a
potential null pointer dereference.
Reported by smatch:
drivers/gpu/drm/amd/amdgpu/../display/dc/resource/dcn201/dcn201_resource.c:1016 dcn201_acquire_free_pipe_for_layer() error: we previously assumed 'head_pipe' could be null (see line 1010)
Cc: Tom Chung <chiahsuan.chung@....com>
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@....com>
Cc: Roman Li <roman.li@....com>
Cc: Alex Hung <alex.hung@....com>
Cc: Aurabindo Pillai <aurabindo.pillai@....com>
Cc: Harry Wentland <harry.wentland@....com>
Cc: Hamza Mahfooz <hamza.mahfooz@....com>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@....com>
Reviewed-by: Tom Chung <chiahsuan.chung@....com>
Signed-off-by: Alex Deucher <alexander.deucher@....com>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
.../gpu/drm/amd/display/dc/resource/dcn201/dcn201_resource.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn201/dcn201_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dcn201/dcn201_resource.c
index 070a4efb308bd..1aeede348bd39 100644
--- a/drivers/gpu/drm/amd/display/dc/resource/dcn201/dcn201_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/resource/dcn201/dcn201_resource.c
@@ -1005,8 +1005,10 @@ static struct pipe_ctx *dcn201_acquire_free_pipe_for_layer(
struct pipe_ctx *head_pipe = resource_get_otg_master_for_stream(res_ctx, opp_head_pipe->stream);
struct pipe_ctx *idle_pipe = resource_find_free_secondary_pipe_legacy(res_ctx, pool, head_pipe);
- if (!head_pipe)
+ if (!head_pipe) {
ASSERT(0);
+ return NULL;
+ }
if (!idle_pipe)
return NULL;
--
2.43.0
Powered by blists - more mailing lists