]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
soc: microchip: mpfs: Fix memory leak in mpfs_sys_controller_probe()
authorZilin Guan <zilin@seu.edu.cn>
Sun, 28 Dec 2025 12:48:36 +0000 (12:48 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 Mar 2026 10:08:51 +0000 (11:08 +0100)
commitda4b44c42f40501db35f5d0a6243708a061490a0
tree6f10528792b71a20dc0553b510b1d4bb2fc6230f
parente6b8133e0f51dfbded42430b59b710798feac053
soc: microchip: mpfs: Fix memory leak in mpfs_sys_controller_probe()

[ Upstream commit 5a741f8cc6fe62542f955cd8d24933a1b6589cbd ]

In mpfs_sys_controller_probe(), if of_get_mtd_device_by_node() fails,
the function returns immediately without freeing the allocated memory
for sys_controller, leading to a memory leak.

Fix this by jumping to the out_free label to ensure the memory is
properly freed.

Also, consolidate the error handling for the mbox_request_channel()
failure case to use the same label.

Fixes: 742aa6c563d2 ("soc: microchip: mpfs: enable access to the system controller's flash")
Co-developed-by: Jianhao Xu <jianhao.xu@seu.edu.cn>
Signed-off-by: Jianhao Xu <jianhao.xu@seu.edu.cn>
Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/soc/microchip/mpfs-sys-controller.c