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 752D22D0C75; Sat, 12 Sep 2026 12:24:08 +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=1789215849; cv=none; b=j9DoH53P273E3W+9lbH/jA5BYT0r47RCdKpBOnBmzAp0HQy3n6W6W1B3Xp7kPyk58RMA7rrr4ejwMVYsFSOCPyBobPFpSaX04L8LYefxygH2ggWaK2XPKj7dSc4O9mU5MDmVt7QQHRMNwTsrl7YxaxcCoQ6H1gig7cGurJ36Sm4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789215849; c=relaxed/simple; bh=QMNCuClYZKB6LEGHDwpPeAwS2noVwnFMPnxGCRm+6M0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WlyPubkMRupib0HfuYL1oCmDNrx7BJzgqjwsX2S7weUH1oXgcJycoUx3xrAWPYyzL00chHtR/yxe7nBmostSHDJOnAnlEfyhjyBYmZvg9tG6fLPc+ezt52RgIfVgry+XR18X7agL6zuOaZfoW2aZE0zcHpUcK1jA46VCdNGT4tg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ZTxsbGY6; 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="ZTxsbGY6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F00A1F000FF; Sat, 12 Sep 2026 12:24:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789215848; bh=GE2QtPPrisVEcTKdXcHZliaVEKP8zyDfmZ67LNpOWlY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ZTxsbGY6VOkCHKBMU0ZyfwNbZGycgBT/IJifd4/FzTPanGetBHA5p7y6+8jJnaiB/ 5TyHpmLM+WpGiuxKbcViBnLJGvPRBq/eEEYh/JsRKUv0FwPP+1f7BHgJ25bdlcqUlj x4wb1s93A3nhrWO26fPchW2ZRdh0c2R8Y9uG2DmQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sashiko AI review , Chen Pei , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 6.12 0617/1376] ACPI: PCI: Clear driver_data on all paths that free the acpi_pci_root Date: Sat, 12 Sep 2026 08:50:43 +0200 Message-ID: <20260912065621.293220953@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065607.535295758@linuxfoundation.org> References: <20260912065607.535295758@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: Chen Pei [ Upstream commit 8a742141f7ab84975aa758b775567ef4740ef0cf ] acpi_pci_root_add() assigns the freshly allocated root to device->driver_data before dmar_device_add() and pci_acpi_scan_root(). Both failure paths reach the end: label where root is kfree()'d, but only the pci_acpi_scan_root() path clears driver_data first. When dmar_device_add() fails during a hot-add, root is freed while device->driver_data still points at it. The ACPI core does not clear driver_data on attach failure, so a later acpi_pci_find_root() call may dereference this dangling pointer. acpi_pci_root_remove() has the same problem: it frees root without clearing device->driver_data, leaving a dangling pointer behind after the root bridge is removed. Move the NULL assignment to the shared end: label so every error path in acpi_pci_root_add() clears driver_data before freeing root, and clear it in acpi_pci_root_remove() as well, so the object is never left reachable through driver_data after being freed. Fixes: db89b4f0dbab ("ACPI: catch calls of acpi_driver_data on pointer of wrong type") Reported-by: Sashiko AI review Link: https://sashiko.dev/#/patchset/20260526025118.38935-1-cp0613@linux.alibaba.com Link: https://sashiko.dev/#/patchset/20260707121258.11640-1-cp0613@linux.alibaba.com Signed-off-by: Chen Pei Link: https://patch.msgid.link/20260715135048.3278-1-cp0613@linux.alibaba.com Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/acpi/pci_root.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index d0bfb37068019..eb36cb77dfa48 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -730,7 +730,6 @@ static int acpi_pci_root_add(struct acpi_device *device, dev_err(&device->dev, "Bus %04x:%02x not present in PCI namespace\n", root->segment, (unsigned int)root->secondary.start); - device->driver_data = NULL; result = -ENODEV; goto remove_dmar; } @@ -766,6 +765,7 @@ static int acpi_pci_root_add(struct acpi_device *device, if (hotadd) dmar_device_remove(handle); end: + device->driver_data = NULL; kfree(root); return result; } @@ -789,6 +789,7 @@ static void acpi_pci_root_remove(struct acpi_device *device) pci_unlock_rescan_remove(); + device->driver_data = NULL; kfree(root); } -- 2.53.0