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 B4BD31DEFEF; Tue, 8 Oct 2024 12:23:42 +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=1728390222; cv=none; b=Oew7RHyLrgM3cCEiguINizWZBv/svSijP3zqAUlqODDMJJDCk665z7LWR2rvDNAwNvh4HhZ+Nv3GioKmL1K8cVosVm7UJJI03BbJVDIQSptx77zu9vETlRlTbPalt2b22iQvbIBivd8FRxiWUss2P5EVJruILex8zBPDA8GHv6A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728390222; c=relaxed/simple; bh=IVslUCw8Fo6iXFZ7xoRDJ4ZLB8poUqE5jrJ8KfmGmRg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ht5lD5uTCcs7OESBoFHu++HsFk5D7mQI13puV10c/G3JE2M69e0vazrEt17S1d9DQd/sJaGOrCbXCGVxYaeFtR5e/RhwVj4J0GXQcz44OyZljakEyhuyrRs3KOP9rb/zWmuKT1ti6VTvofsnWfN+PfLEGdqvlkqMJ7N9jaazbWE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=qxFC9R+b; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="qxFC9R+b" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F111C4CECD; Tue, 8 Oct 2024 12:23:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728390222; bh=IVslUCw8Fo6iXFZ7xoRDJ4ZLB8poUqE5jrJ8KfmGmRg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qxFC9R+bMxn6IBEC25WAx8Oby8SVkzn08c6Gds61VWe8LUucTfmomMtHWx5ch+3XV ToJlfKb6P/wk8V4PDvmaZGdodajD0XJRzabYTGwN5sEn4B2I8PtL3U/u1lyXNXNT9U RdJV9osuTHl8k0OqYJrJ7HZ4eCPgvmCiFFrgG8gM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yang Wang , Tao Zhou , Alex Deucher , Sasha Levin Subject: [PATCH 6.10 195/482] drm/amdgpu: add list empty check to avoid null pointer issue Date: Tue, 8 Oct 2024 14:04:18 +0200 Message-ID: <20241008115655.978903526@linuxfoundation.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241008115648.280954295@linuxfoundation.org> References: <20241008115648.280954295@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yang Wang [ Upstream commit 4416377ae1fdc41a90b665943152ccd7ff61d3c5 ] Add list empty check to avoid null pointer issues in some corner cases. - list_for_each_entry_safe() Signed-off-by: Yang Wang Reviewed-by: Tao Zhou Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c index 9baee7c246b6d..a513819b72311 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c @@ -80,6 +80,9 @@ static void aca_banks_release(struct aca_banks *banks) { struct aca_bank_node *node, *tmp; + if (list_empty(&banks->list)) + return; + list_for_each_entry_safe(node, tmp, &banks->list, node) { list_del(&node->node); kvfree(node); @@ -562,9 +565,13 @@ static void aca_error_fini(struct aca_error *aerr) struct aca_bank_error *bank_error, *tmp; mutex_lock(&aerr->lock); + if (list_empty(&aerr->list)) + goto out_unlock; + list_for_each_entry_safe(bank_error, tmp, &aerr->list, node) aca_bank_error_remove(aerr, bank_error); +out_unlock: mutex_destroy(&aerr->lock); } @@ -680,6 +687,9 @@ static void aca_manager_fini(struct aca_handle_manager *mgr) { struct aca_handle *handle, *tmp; + if (list_empty(&mgr->list)) + return; + list_for_each_entry_safe(handle, tmp, &mgr->list, node) amdgpu_aca_remove_handle(handle); } -- 2.43.0