]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
spi: atcspi200: fix mutex initialization order
authorPei Xiao <xiaopei01@kylinos.cn>
Thu, 12 Mar 2026 02:47:55 +0000 (10:47 +0800)
committerMark Brown <broonie@kernel.org>
Thu, 12 Mar 2026 11:28:31 +0000 (11:28 +0000)
commit869d5b4b2a8012f6ef6058a1055cac6922c2cb55
tree42a2ca130e8676defe2767a5b46106d86869b967
parent97545e37234fdbe457f5104a09f55033550b3d84
spi: atcspi200: fix mutex initialization order

The atcspi_exec_mem_op() function may call mutex_lock() on the
driver's mutex before it is properly initialized if a SPI memory
operation is initiated immediately after devm_spi_register_controller()
is called. The mutex initialization currently occurs after the
controller registration, which leaves a window where the mutex could
be used uninitialized.

Move the mutex initialization to the beginning of the probe function,
before any registration or resource allocation.

Fixes: 34e3815ea459 ("spi: atcspi200: Add ATCSPI200 SPI controller driver")
Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
Link: https://patch.msgid.link/15a71241affc25108a97d40d9d3dd1bc3d2d69ed.1773282905.git.xiaopei01@kylinos.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-atcspi200.c