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 22BED3AC0DC; Thu, 2 Jul 2026 16:26:40 +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=1783009603; cv=none; b=eoMBGCD/MEpF8ESYbX0TkyAbFt2X3ATn940bZBNvZmGKb2nbyBIPSTss4avPgyRXTCn6RaiFRYwMpFaDI8QEV30t+NhvxrolzCgcLc1MWHYi4wuRQUc3R/BZBiRiITI34FHdzQe0ZQo3/pVKKvSY0xQ2Yu2eGCYfxw4l07YLdNg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783009603; c=relaxed/simple; bh=1n0hSwSRyn3M99NVePCQwcGLvloVBLjv004VSUKxzsE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HCO0ubR9f4UMq6f2Ca/jb1irQn+qPX6qKSIxAVQabGlmLl8P9K7i7ndMX5W76tqhZV9cbFBcHyUNHzsZDstsdNjmsx+TLUwznL2VDpad5QQpg0/OB4c7lU1XGdQ7LNTOupG60Dlrk6hT8U5SglmcKronWOzdxkbiUQnbcFORPvY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=QTck3o+q; 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="QTck3o+q" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F8BC1F000E9; Thu, 2 Jul 2026 16:26:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1783009599; bh=tqQUdsmdK+ynkMBCwbCAPa+cGo3qqPghDm8nQv2n5+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=QTck3o+qPvux+ZB8et+mrA86JdviAHo/5izNM3kH6vDgoDR38jZAyoKp+z7nSYNuf 2L0sVTRUG3vTxV18cjb7aS2KSaleK2mcZjRXLKP5DyENIuB7QEIoV8t0Cfgx/OT6+8 xMo2nB9trYj6RxrLLF2Id7p1pVRjJDLPedYM+kGk= 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 5.15 17/95] agp/amd64: Fix broken error propagation in agp_amd64_probe() Date: Thu, 2 Jul 2026 18:19:20 +0200 Message-ID: <20260702155109.568304786@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260702155109.196223802@linuxfoundation.org> References: <20260702155109.196223802@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 5.15-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; }