]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
i2c: amd-mp2: fix reference leak in MP2 PCI device
authorMa Ke <make24@iscas.ac.cn>
Wed, 22 Oct 2025 09:54:02 +0000 (17:54 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Jan 2026 12:09:54 +0000 (13:09 +0100)
commitac45b270ea28808f74598625e2c0d43db25a86ed
tree713d9d12f0a710c239eed922fc4ef61ecc716cfa
parent24fd02c3a4798de7dc94b55d36a1685fe6cdaf69
i2c: amd-mp2: fix reference leak in MP2 PCI device

commit a6ee6aac66fb394b7f6e6187c73bdcd873f2d139 upstream.

In i2c_amd_probe(), amd_mp2_find_device() utilizes
driver_find_next_device() which internally calls driver_find_device()
to locate the matching device. driver_find_device() increments the
reference count of the found device by calling get_device(), but
amd_mp2_find_device() fails to call put_device() to decrement the
reference count before returning. This results in a reference count
leak of the PCI device each time i2c_amd_probe() is executed, which
may prevent the device from being properly released and cause a memory
leak.

Found by code review.

Cc: stable@vger.kernel.org
Fixes: 529766e0a011 ("i2c: Add drivers for the AMD PCIe MP2 I2C controller")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://lore.kernel.org/r/20251022095402.8846-1-make24@iscas.ac.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/i2c/busses/i2c-amd-mp2-pci.c