i2c: amd-mp2: Unregister callback on adapter add failure
authorMyeonghun Pak <mhun512@gmail.com>
Tue, 21 Jul 2026 14:41:47 +0000 (23:41 +0900)
committerAndi Shyti <andi.shyti@kernel.org>
Mon, 27 Jul 2026 20:52:34 +0000 (22:52 +0200)
commit82048795242f04275a3f49ffc66ad851b6120954
tree5e2b81fe11ab62c0dfecad7a128849e33c7dfb05
parentcdac670237258c8ca063aa8a16998f680d81b80d
i2c: amd-mp2: Unregister callback on adapter add failure

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 <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
Cc: <stable@vger.kernel.org> # v5.2+
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://lore.kernel.org/r/20260721144147.31150-1-mhun512@gmail.com
drivers/i2c/busses/i2c-amd-mp2-plat.c