]> git.ipfire.org Git - thirdparty/kernel/linux.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)
committerMark Brown <broonie@kernel.org>
Mon, 12 Jan 2026 11:20:42 +0000 (11:20 +0000)
commit383d4f5cffcc8df930d95b06518a9d25a6d74aac
tree2ecf4588c76fd9df7d308f7d3550fecec9bf1ed3
parent9ace4753a5202b02191d54e9fdf7f9e3d02b85eb
spi: spi-sprd-adi: Fix double free in probe error path

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>
drivers/spi/spi-sprd-adi.c