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 D123AC3DA64 for ; Thu, 1 Aug 2024 00:37:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 47C1E10E854; Thu, 1 Aug 2024 00:37:52 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="FwkT86bE"; dkim-atps=neutral Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8782010E84C; Thu, 1 Aug 2024 00:37:50 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id A978CCE1764; Thu, 1 Aug 2024 00:37:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C3C7C4AF0C; Thu, 1 Aug 2024 00:37:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722472667; bh=/TJO27vsNKgNcS2i3huSkC6KKLh0ladBKB8pVWogTbg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FwkT86bESd+t9ct/HNYl4JkeL0ZkUB6S47jIWpppt7Q8NfYH5QgI8hJYjgXwBWMhv whWLTRy0TseqK61wuqFPKejaWtFPd+BX+THJnJQXBnUKCFokIpOFmOWYKGsb7lSHPW fEJsJJ63XHvCJEaS4MdiCLiJVW13Ihf0TKTd2qz0/aaERnYrOwzrfcHdjFkIPYNRL1 7/7ApJEgn96w0RexhKpeymEvxb8Ck/h+s2lnYjuVv5Qoa2YXZdMqHaU6lL9tD+0Otm Hvt99NWR2VZ07fb3tAb5QCsTdrvpB0FV5n5TImr9OBoNXVGm4BMyjAMXD/Quhb2vS7 U0kfkdvWc54Ow== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Tim Huang , Alex Deucher , Sasha Levin , christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, Hawking.Zhang@amd.com, lijo.lazar@amd.com, electrodeyt@gmail.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.10 14/38] drm/amdgpu: fix mc_data out-of-bounds read warning Date: Wed, 31 Jul 2024 20:35:20 -0400 Message-ID: <20240801003643.3938534-14-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801003643.3938534-1-sashal@kernel.org> References: <20240801003643.3938534-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.10.223 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: , Errors-To: amd-gfx-bounces@lists.freedesktop.org Sender: "amd-gfx" From: Tim Huang [ Upstream commit 51dfc0a4d609fe700750a62f41447f01b8c9ea50 ] Clear warning that read mc_data[i-1] may out-of-bounds. Signed-off-by: Tim Huang Reviewed-by: Alex Deucher Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c index 469352e2d6ecf..436d436b2ea23 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c @@ -1626,6 +1626,8 @@ int amdgpu_atombios_init_mc_reg_table(struct amdgpu_device *adev, (u32)le32_to_cpu(*((u32 *)reg_data + j)); j++; } else if ((reg_table->mc_reg_address[i].pre_reg_data & LOW_NIBBLE_MASK) == DATA_EQU_PREV) { + if (i == 0) + continue; reg_table->mc_reg_table_entry[num_ranges].mc_data[i] = reg_table->mc_reg_table_entry[num_ranges].mc_data[i - 1]; } -- 2.43.0