From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796385067; b=VTytnQECcWZu0BkAjyAN4Q4zEwm6JWqsDX7PlvNb75o8ipoE4oO9ZCGNiR19Co0adm6V SRJsk1QKp7M98Hi7Ac6MHvE/EqRhrzyIAWI3p1tvQ4ZrN9K05Q6nQVXUao4qfkCqa5D/8 XXkcA5C3PKgYGY3QiVcuSIFILbBAHxdSNLnfgLzCtvf447SyBA3O0pW45thxtWu7uctV9 u4FpW2iC78nYUFFPDoCSvqjPAelCI0FHqESTbIBEy/kWxY+XOh3dkxG7LY4EKfJMwoExl knNgMQ1Duh500QDTwO7djGaW44tyvuETtJHegD579Wn9kmohWSE2I+VPE1iB+/P93UQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385067; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=3pS+ezCHw79uK6na4C1yAA2rYfZmMMF8HXFIjkjUmRI=; b=jJZas/UoDLXz8N07T/+IUvzd6fqYmGscyICMibLCGQG65Lz+LDJl7l+/Na3Bthjwoayg vfgRvE62g+sjw1QK1gawWSzpFExXcH+PKr05HgPZIdhuc5m/nUFb90cqiTFASc+f6t/w8 /fc7jZ6a7lFH9JHTAzcd+3Hei55K9H7BVFOquEtdMmwlKrtsK5H6TIvxr11ool2+InhUM 7koFARveJx6kkXNqjWby64X2quNSWs2tDdbYzsy/XiSCqXoNH1oluMfyT32HYzIT80XO/ 2b07ciuMljzxed5hXwrDCvh1UZGyDs7PpQNpYiCBg0ibBEhpQanjCKJQhN2LgSldLUw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Lw2IfN1a; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F1A71606A32C; Fri, 4 Dec 2026 11:51:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Lw2IfN1a Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BDA81F000CE; Fri, 4 Dec 2026 11:51:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385066; bh=3pS+ezCHw79uK6na4C1yAA2rYfZmMMF8HXFIjkjUmRI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Lw2IfN1aXU4rk4Ixd7oMiHmtSPA+yQ3KpszoyX9ytOU4vcgsDen5dz9B88biCF7ab VWQ5ELmpqUf9a/yfdk/6/ta4arWKUx1SIHq4we4hkk2nbB2cg00GcFZkM/SAkap20G p0BXG3yVYTm5r+MOTWk8hD5nuRXfuyccg3HzvFbg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Shyam Sundar S K , "Mario Limonciello (AMD)" , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Sasha Levin Subject: [PATCH 6.6 0404/1167] platform/x86/amd/pmc: clear devm-managed pointers on remove to prevent stale reuse Date: Fri, 4 Dec 2026 18:57:11 +0900 Message-ID: <20261204100712.548595070@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shyam Sundar S K [ Upstream commit c9ba86f5411730ebd333d94b9e1aa8f652dc743f ] The driver stores its state in a single file-scope static struct amd_pmc_dev, which is reused on every bind. Its regbase, smu_virt_addr, stb_virt_addr and fch_virt_addr members are MMIO mappings created with devm_ioremap(). On unbind the driver core unmaps these mappings, but it does not clear the pointers in the static struct. Since the struct is not freed, the members keep pointing at the now-unmapped addresses. On the next bind, the probe path re-maps a region only when its pointer is still NULL, so the stale pointer is reused and the following memcpy_fromio()/ioread32() touches freed MMIO, causing use-after-unmap crash. Clear these pointers in amd_pmc_remove() so the next probe re-maps them instead of reusing stale ones. Signed-off-by: Shyam Sundar S K Reviewed-by: Mario Limonciello (AMD) Fixes: 156ec4731cb22b ("platform/x86: amd-pmc: Add AMD platform support for S2Idle") Link: https://patch.msgid.link/20260929155609.1712638-1-Shyam-sundar.S-k@amd.com Reviewed-by: Ilpo Järvinen Signed-off-by: Ilpo Järvinen [ sashal: Added the four NULL assignments at the end of amd_pmc_remove() after mutex_destroy(), since the MP2 STB deinit call in the upstream context is not present in this tree. ] Signed-off-by: Sasha Levin --- drivers/platform/x86/amd/pmc/pmc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/platform/x86/amd/pmc/pmc.c b/drivers/platform/x86/amd/pmc/pmc.c index 19abca2e46763..690df8746cf52 100644 --- a/drivers/platform/x86/amd/pmc/pmc.c +++ b/drivers/platform/x86/amd/pmc/pmc.c @@ -1163,6 +1163,10 @@ static void amd_pmc_remove(struct platform_device *pdev) amd_pmc_dbgfs_unregister(dev); pci_dev_put(dev->rdev); mutex_destroy(&dev->lock); + dev->regbase = NULL; + dev->smu_virt_addr = NULL; + dev->stb_virt_addr = NULL; + dev->fch_virt_addr = NULL; } static const struct acpi_device_id amd_pmc_acpi_ids[] = { -- 2.53.0