]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
spi: spi-sprd-adi: Fix double free in probe error path
authorFelix Gu <gu_0233@qq.com>
Fri, 9 Jan 2026 12:49:53 +0000 (20:49 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 30 Jan 2026 09:27:35 +0000 (10:27 +0100)
commit417cdfd9b9f986e95bfcb1d68eb443e6e0a15f8c
tree8df94d182d4208082f92b8c332b5a009b1a8c6ac
parent1a27bd3c6949f0c4ffb4682fc32a0cb88458f85f
spi: spi-sprd-adi: Fix double free in probe error path

[ Upstream commit 383d4f5cffcc8df930d95b06518a9d25a6d74aac ]

The driver currently uses spi_alloc_host() to allocate the controller
but registers it using devm_spi_register_controller().

If devm_register_restart_handler() fails, the code jumps to the
put_ctlr label and calls spi_controller_put(). However, since the
controller was registered via a devm function, the device core will
automatically call spi_controller_put() again when the probe fails.
This results in a double-free of the spi_controller structure.

Fix this by switching to devm_spi_alloc_host() and removing the
manual spi_controller_put() call.

Fixes: ac17750 ("spi: sprd: Add the support of restarting the system")
Signed-off-by: Felix Gu <gu_0233@qq.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Link: https://patch.msgid.link/tencent_AC7D389CE7E24318445E226F7CDCCC2F0D07@qq.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/spi/spi-sprd-adi.c