From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 79748C433F5 for ; Sun, 9 Oct 2022 23:57:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A81B410E5EE; Sun, 9 Oct 2022 23:57:15 +0000 (UTC) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by gabe.freedesktop.org (Postfix) with ESMTPS id E21AB10E5EC; Sun, 9 Oct 2022 23:57:11 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8079AB80DE9; Sun, 9 Oct 2022 23:57:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14352C433C1; Sun, 9 Oct 2022 23:57:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665359830; bh=Pz9ZsItQ1uNJr7qgBMr/+xmodQ2vsCKTlDPfXXmZrXo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PbF2rZNH6PokwlDlA5ycKC+Q45KNnAN8muOQLT5E6pM/U0yFpZQfZx69PSWL0O9/S /b3mSW6krKAV6/D36K5G3EHnZ4fh91FiHFzd5ZMOM5gsc8meJV98ZzX+fhfqYaPpHA ac/eiP5jOOA5W+DCiZyuXTGeID/4pgoAxqxi900zkRnwxmjQgqCuFkOYXmaxKyvW2k NWGZf+dJSNQC/e07T8Y/UGM5qjNcTBkHg1se7QsliP4iwq0CfvDYAgmEdUW6NfgqxE lMpzlWHnDYFTkXi49P36NYq9TbpqnY35qHEfoG9QuJSrzbF/vJfPGQrbRZBbh+vpER NInEXe/Wo37mw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH AUTOSEL 5.10 22/22] drm/amd/display: fix array-bounds error in dc_stream_remove_writeback() Date: Sun, 9 Oct 2022 19:55:40 -0400 Message-Id: <20221009235540.1231640-22-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221009235540.1231640-1-sashal@kernel.org> References: <20221009235540.1231640-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sasha Levin , amd-gfx@lists.freedesktop.org, sunpeng.li@amd.com, airlied@gmail.com, dri-devel@lists.freedesktop.org, Xinhui.Pan@amd.com, Rodrigo.Siqueira@amd.com, hersenwu@amd.com, alex.hung@amd.com, Aurabindo Pillai , paul.hsieh@amd.com, Hamza Mahfooz , daniel@ffwll.ch, Alex Deucher , hanghong.ma@amd.com, Pavle.Kotarac@amd.com, harry.wentland@amd.com, christian.koenig@amd.com, Jimmy.Kizito@amd.com, Alvin.Lee2@amd.com Errors-To: amd-gfx-bounces@lists.freedesktop.org Sender: "amd-gfx" From: Hamza Mahfooz [ Upstream commit 5d8c3e836fc224dfe633e41f7f2856753b39a905 ] Address the following error: drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_stream.c: In function ‘dc_stream_remove_writeback’: drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_stream.c:527:55: error: array subscript [0, 0] is outside array bounds of ‘struct dc_writeback_info[1]’ [-Werror=array-bounds] 527 | stream->writeback_info[j] = stream->writeback_info[i]; | ~~~~~~~~~~~~~~~~~~~~~~^~~ In file included from ./drivers/gpu/drm/amd/amdgpu/../display/dc/dc.h:1269, from ./drivers/gpu/drm/amd/amdgpu/../display/dc/inc/core_types.h:29, from ./drivers/gpu/drm/amd/amdgpu/../display/dc/basics/dc_common.h:29, from drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_stream.c:27: ./drivers/gpu/drm/amd/amdgpu/../display/dc/dc_stream.h:241:34: note: while referencing ‘writeback_info’ 241 | struct dc_writeback_info writeback_info[MAX_DWB_PIPES]; | Currently, we aren't checking to see if j remains within writeback_info[]'s bounds. So, add a check to make sure that we aren't overflowing the buffer. Reviewed-by: Aurabindo Pillai Signed-off-by: Hamza Mahfooz Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c index d48fd87d3b95..867b8b66293a 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c @@ -491,7 +491,7 @@ bool dc_stream_remove_writeback(struct dc *dc, } /* remove writeback info for disabled writeback pipes from stream */ - for (i = 0, j = 0; i < stream->num_wb_info; i++) { + for (i = 0, j = 0; i < stream->num_wb_info && j < MAX_DWB_PIPES; i++) { if (stream->writeback_info[i].wb_enabled) { if (i != j) /* trim the array */ -- 2.35.1