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 3A376C3DA7F for ; Thu, 1 Aug 2024 00:37:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BB2AF10E84A; Thu, 1 Aug 2024 00:37:37 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="BhCw9EiY"; dkim-atps=neutral Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1A2FE10E849; Thu, 1 Aug 2024 00:37:36 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 88B8C624B0; Thu, 1 Aug 2024 00:37:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79A92C32786; Thu, 1 Aug 2024 00:37:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722472655; bh=k75stHD32wBEPIDsCFSMR2r2v5yJTF1MaAXt/r7yYHA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BhCw9EiYiFcxY2DY2KAoabMCVTnkk9R1Dc+kxDoLSl2GMTKkIoE4ws9mFtNKj9HFh nKEnJ1rnv3OxsZdzpnJkmaN8Pkalm7CC2gBj6IkrgT6bPtWaVSA60BLhJ6NMYxfTlN 0KXkFbRpUIfZQBmWjgzueO9yBqYhqbBeuKzqBHct5bMv7cnt5E557EhOYYh/42uJXf sTUlR6ww0V2Ql/2BnlmXU8KKjnw5GKwiu3o7bKzx3kQnmmbdexMcdQQ7gRhJZ8GSZ8 ltcOOMP0XOALq2vf89BJm++051B65W8i6WjLsDXiYI9yWmk1RA4I9JmU2qSTjJs7bJ kg/kqDzcvwRRA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ma Jun , =?UTF-8?q?Christian=20K=C3=B6nig?= , Tim Huang , Alex Deucher , Sasha Levin , Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, shashank.sharma@amd.com, hannes@cmpxchg.org, friedrich.vock@gmx.de, andrealmeid@igalia.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.10 11/38] drm/amdgpu: Fix out-of-bounds write warning Date: Wed, 31 Jul 2024 20:35:17 -0400 Message-ID: <20240801003643.3938534-11-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 Content-Type: text/plain; charset=UTF-8 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: Ma Jun [ Upstream commit be1684930f5262a622d40ce7a6f1423530d87f89 ] Check the ring type value to fix the out-of-bounds write warning Signed-off-by: Ma Jun Suggested-by: Christian König Reviewed-by: Tim Huang Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c index 6976f61be7341..b78feb8ba01e1 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c @@ -260,7 +260,7 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring, ring->priority = DRM_SCHED_PRIORITY_NORMAL; mutex_init(&ring->priority_mutex); - if (!ring->no_scheduler) { + if (!ring->no_scheduler && ring->funcs->type < AMDGPU_HW_IP_NUM) { hw_ip = ring->funcs->type; num_sched = &adev->gpu_sched[hw_ip][hw_prio].num_scheds; adev->gpu_sched[hw_ip][hw_prio].sched[(*num_sched)++] = -- 2.43.0