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 2E80D280331; Fri, 7 Aug 2026 15:44:15 +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=1786117456; cv=none; b=Dw9lFrIBYs9uo7D0Z4B6T/L9HBtx88gbQXw+PZq3a5vMLsR3sSkqsUp9/5F68pZQOATBZpepYCb1AWJH/uePtvjGlfxBDjucFBxaGQBK056JO0bAI4hMaLsI6QawntAFRkv/lSZnVHd3IoJ5SPHFy+KPFQOb5zKrcfH76ncrL7A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786117456; c=relaxed/simple; bh=/3RU1eY5WoQnB54zxNnfMmwf419c+5stUZI0RnFU8wM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l47KyRCxLZi50orEn9LQrpRD7hqPKXUGX8/lNGOL5buhtj6afQEgmld5+Xv3TviV/ZvS1VkKyxOrc8yygqhy6qk276HMJ16FZ/4li6UMGBKPHVxW02QDagU+R3z994+Z/PQeryd0Bg0XZdgztIe8tvNM8zjC6qn/K3Db2+QtRQQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=icHgFe20; 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="icHgFe20" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A2401F000E9; Fri, 7 Aug 2026 15:44:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786117455; bh=39C0pPPMYP0DZSjWpaStQWynVMINn3Lcp28bF2UgxiI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=icHgFe20uYFviB1kPSKlQ03l31CYH4Fx2P3onKDZjLhMIK9+cTn8YZZ3D8WuU3yWE PpP9Rp4Kn2vYLP1/F2mWfG83gV1mutYsx5wcPWsjp/seoHqItMRGXSdxYA/C1g1von 5IeAALaCAyTK/RvaR84VGlXCmmwI7IQ7bCbfXhsw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ijae Kim , Myeonghun Pak , Andi Shyti Subject: [PATCH 7.1 325/438] i2c: amd-mp2: Unregister callback on adapter add failure Date: Fri, 7 Aug 2026 16:38:41 +0200 Message-ID: <20260807143434.903714178@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260807143428.008222056@linuxfoundation.org> References: <20260807143428.008222056@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 7.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Myeonghun Pak commit 82048795242f04275a3f49ffc66ad851b6120954 upstream. amd_mp2_register_cb() stores the platform I2C context in the MP2 PCI driver's callback table before the adapter is registered. If i2c_add_adapter() fails, probe returns and devres frees the context, but the PCI driver can still dereference the stale pointer from its IRQ and system-sleep callbacks. Unregister the callback before returning the adapter registration error. Fixes: 529766e0a011 ("i2c: Add drivers for the AMD PCIe MP2 I2C controller") Co-developed-by: Ijae Kim Signed-off-by: Ijae Kim Signed-off-by: Myeonghun Pak Cc: # v5.2+ Signed-off-by: Andi Shyti Link: https://lore.kernel.org/r/20260721144147.31150-1-mhun512@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-amd-mp2-plat.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/i2c/busses/i2c-amd-mp2-plat.c +++ b/drivers/i2c/busses/i2c-amd-mp2-plat.c @@ -316,8 +316,10 @@ static int i2c_amd_probe(struct platform amd_mp2_pm_runtime_put(mp2_dev); - if (ret < 0) + if (ret < 0) { dev_err(&pdev->dev, "i2c add adapter failed = %d\n", ret); + amd_mp2_unregister_cb(&i2c_dev->common); + } return ret; }