From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 EDE572D8DC4; Thu, 2 Jul 2026 16:37:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783010229; cv=none; b=KS/2Fl1+xu0K5iaRvXOJixsru/YuCYaBGTw0pp+QnMuQBofDbtm9ez5Jo32n/9DEmNzXqMY7IVv4AFRdDwdxo4hgWEnCoPaRj4+3/b7BKUszsfLf/KsMgskmGR/umIo3iL7ZsuhD2RU9v3s0XwMBoj0v8U9ru8r62eQsb8pyjn8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783010229; c=relaxed/simple; bh=Yb1UrjjM2hAr+jIsD3lsUkmfXNWF9/2Q1K/xuryigBI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pESO/dQ34gsaE98Vr/V0+jMSDD/8fTQrHLZdkuo8RhLLtcBMR9BGKsctVy+xTyI9wHYP+WrKdmUky+A7RACxNsbqnq0/7BKxsPGemp14XBwGxwe291gOxnn65oj37V3rpHSWaQgDVc5/BT/FCY22uJi6HJs4WN6HHgrtZmDEkHQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=QOAvza1N; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="QOAvza1N" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 189291F000E9; Thu, 2 Jul 2026 16:37:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1783010227; bh=AzPpZgRL35S+FLdILyIq+PvC9aqxNEWswMVGHwTTwsA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=QOAvza1NbNbavmKCdSDbjYMjfJTVBVuYx3MxNIiMPMIBpGm3awfjHT4OAof84a3hI Fm1dxIgWVGpJq46ODNmzCFXIJPmoBNDDAmyV9COMg9t7vok8sVb/Ly+1AwU0NOtZWO nXyTPChPAQXWoY3W5DVg8kJ6Obq92NdEigJ0SQMs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mingyu Wang <25181214217@stu.xidian.edu.cn>, Lukas Wunner Subject: [PATCH 6.12 030/204] agp/amd64: Fix broken error propagation in agp_amd64_probe() Date: Thu, 2 Jul 2026 18:18:07 +0200 Message-ID: <20260702155119.291579537@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260702155118.667618796@linuxfoundation.org> References: <20260702155118.667618796@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mingyu Wang <25181214217@stu.xidian.edu.cn> commit b08472db93b1ccff84a7adec5779d47f0e9d3a30 upstream. A NULL pointer dereference was observed in the AMD64 AGP driver when running in a virtualized environment (e.g. qemu/kvm) without a physical AMD northbridge. The crash occurs in amd64_fetch_size() when attempting to dereference the pointer returned by node_to_amd_nb(0). The root cause of this crash is broken error propagation in agp_amd64_probe(): When no AMD northbridges are found, cache_nbs() correctly returns -ENODEV. However, the probe function erroneously checks the return value against exactly -1, rather than < 0. As a result, the hardware absence error is masked, allowing the driver to improperly proceed with initialization. It eventually calls agp_add_bridge(), which invokes amd64_fetch_size(). Since the hardware does not exist, node_to_amd_nb(0) returns NULL, leading to a General Protection Fault (GPF) when accessing its ->misc member. Fix the issue by correcting the error check in agp_amd64_probe() to abort properly when cache_nbs() returns any negative error code. This prevents the driver from erroneously proceeding without hardware, thereby avoiding the subsequent NULL pointer dereference at its source. Fixes: a32073bffc65 ("[PATCH] x86_64: Clean and enhance up K8 northbridge access code") Signed-off-by: Mingyu Wang <25181214217@stu.xidian.edu.cn> Signed-off-by: Lukas Wunner Reviewed-by: Lukas Wunner Cc: stable@vger.kernel.org # v2.6.18+ Link: https://patch.msgid.link/20260504074823.99377-1-w15303746062@163.com Signed-off-by: Greg Kroah-Hartman --- drivers/char/agp/amd64-agp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/char/agp/amd64-agp.c +++ b/drivers/char/agp/amd64-agp.c @@ -546,7 +546,7 @@ static int agp_amd64_probe(struct pci_de /* Fill in the mode register */ pci_read_config_dword(pdev, bridge->capndx+PCI_AGP_STATUS, &bridge->mode); - if (cache_nbs(pdev, cap_ptr) == -1) { + if (cache_nbs(pdev, cap_ptr) < 0) { agp_put_bridge(bridge); return -ENODEV; }