From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE67518E77B; Wed, 25 Sep 2024 11:44:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727264688; cv=none; b=KCG4XJaG8/2glOkg91eqqe9XgVhZ1y8EyZQzbOu77LT9W3+bfbtUKwj/iAWTPQPaDUaCzfxr2MP3tJy9Q+Q5727JLwNBboVTDn/y6TXTt7ad0pagdtBp2OUl3Q2S7G+GoUBZvGVuOmtYdZIYXPmHthOTSQDlNfgmgW5FseVKT6c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727264688; c=relaxed/simple; bh=J/iNWEt1dVh3szrnpD6JuUBzxBJP3jyAjbsOK6FiW9s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VoFx1q8WIuIbXE90jMARs9Rng92WHG+EKz5RPC1xURBLF2jzFTobf8Q7uGE4SPIWNZYnM233O9E9UfbLK+jz/BziPHIcx8/5evJNiEi0h0l3mjP8agtCIYCe4tMQt3UUkQZI7muw4amygJ66ZSheFnVg/zeYxB8cSuWpgUY3/fw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=P1+Iw9jj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="P1+Iw9jj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA532C4CED0; Wed, 25 Sep 2024 11:44:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727264688; bh=J/iNWEt1dVh3szrnpD6JuUBzxBJP3jyAjbsOK6FiW9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P1+Iw9jjDBkM3OECQmsQQFxjulxNJFgpCiOSwFU8fDCmmGRBfcNUhe+HeM7QtkhKQ DtiBVxqoWtUZYVP3/Skk1mEeBXRulz+/UYDFNvyiHWumPPNSAtJS3xHH+jQAN+yRHD hdpi8uNWYdFuOLDYNMQU7UDCLKl0Xoocqln0EJovGzjeqtGMKi5z4m47iCjvM9b2hG sj2a1io5+JEyZh0ArWxvSdlT7/M6DVmaW3z862t/LAPBkPAWjn+dFhEFrG66UbARKe E09stdPAohOJAbkhYp5FT13TRatntUoAWRXYa+BUseleqnb2MskcHHitQQYcGlKVrj m1oiH2b8e4VFQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Srinivasan Shanmugam , Tom Chung , Rodrigo Siqueira , Roman Li , Alex Hung , Aurabindo Pillai , Harry Wentland , Hamza Mahfooz , Alex Deucher , Sasha Levin , sunpeng.li@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, alvin.lee2@amd.com, wenjing.liu@amd.com, dillon.varone@amd.com, moadhuri@amd.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 6.11 137/244] drm/amd/display: Add null check for head_pipe in dcn32_acquire_idle_pipe_for_head_pipe_in_layer Date: Wed, 25 Sep 2024 07:25:58 -0400 Message-ID: <20240925113641.1297102-137-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240925113641.1297102-1-sashal@kernel.org> References: <20240925113641.1297102-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.11 Content-Transfer-Encoding: 8bit From: Srinivasan Shanmugam [ Upstream commit ac2140449184a26eac99585b7f69814bd3ba8f2d ] This commit addresses a potential null pointer dereference issue in the `dcn32_acquire_idle_pipe_for_head_pipe_in_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/dcn32/dcn32_resource.c:2690 dcn32_acquire_idle_pipe_for_head_pipe_in_layer() error: we previously assumed 'head_pipe' could be null (see line 2681) Cc: Tom Chung Cc: Rodrigo Siqueira Cc: Roman Li Cc: Alex Hung Cc: Aurabindo Pillai Cc: Harry Wentland Cc: Hamza Mahfooz Signed-off-by: Srinivasan Shanmugam Reviewed-by: Tom Chung Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- .../gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c index a43ffa53890af..6e2a08a9572b8 100644 --- a/drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c +++ b/drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c @@ -2674,8 +2674,10 @@ static struct pipe_ctx *dcn32_acquire_idle_pipe_for_head_pipe_in_layer( struct resource_context *old_ctx = &stream->ctx->dc->current_state->res_ctx; int head_index; - if (!head_pipe) + if (!head_pipe) { ASSERT(0); + return NULL; + } /* * Modified from dcn20_acquire_idle_pipe_for_layer -- 2.43.0