spi: spi-imx: Add check for spi_imx_setupxfer()
Subsystems (2)
PATCH 1/1 spi: spi-imx: Add check for spi_imx_setupxfer()
Add check for the return value of spi_imx_setupxfer(). spi_imx->rx and spi_imx->tx function pointer can be NULL when spi_imx_setupxfer() return error, and make NULL pointer dereference.
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 Call trace: 0x0 spi_imx_pio_transfer+0x50/0xd8 spi_imx_transfer_one+0x18c/0x858 spi_transfer_one_message+0x43c/0x790 __spi_pump_transfer_message+0x238/0x5d4 __spi_sync+0x2b0/0x454 spi_write_then_read+0x11c/0x200
--- drivers/spi/spi-imx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/spi/spi-imx.c +4 -1
@@ -1695,9 +1695,12 @@ static int spi_imx_transfer_one(struct spi_controller *controller,struct spi_device *spi, struct spi_transfer *transfer) { + int ret;struct spi_imx_data *spi_imx =spi_controller_get_devdata (spi->controller); -spi_imx_setupxfer (spi, transfer); + ret =spi_imx_setupxfer (spi, transfer); +if (ret <0 ) +return ret; transfer->effective_speed_hz = spi_imx->spi_bus_clk;/* flush rxfifo before transfer */
Signature · 1 line
2.47.2
Hi, Thank you for fix.
Quoted 60 lines
-----Original Message-----
From: Tamura Dai <[email protected]>
Sent: Thursday, April 17, 2025 9:16 AM
To: Mark Brown <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Tamura Dai <[email protected]>
Subject: [EXT] [PATCH] spi: spi-imx: Add check forspi_imx_setupxfer()[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
Caution: This is an external email. Please take care when clicking links or opening attachments. When in doubt, report the message using the 'Report this email' button
Add check for the return value of
spi_imx_setupxfer().spi_imx->rxandspi_imx->txfunction pointer can be NULL whenspi_imx_setupxfer()return error, and make NULL pointer dereference.Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 Call trace: 0x0 spi_imx_pio_transfer+0x50/0xd8 spi_imx_transfer_one+0x18c/0x858 spi_transfer_one_message+0x43c/0x790 __spi_pump_transfer_message+0x238/0x5d4 __spi_sync+0x2b0/0x454 spi_write_then_read+0x11c/0x200Signed-off-by Tamura Dai <[email protected]>--- drivers/spi/spi-imx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/spi/spi-imx.c index renamed from drivers/spi/spi-imx.c +0
-0
832d6e9009eb..c93d80a4d734100644drivers/spi/spi-imx.c +4
-1@@ -1695,9 +1695,12 @@ static int spi_imx_transfer_one(structspi_controller *controller, struct spi_device *spi, struct spi_transfer *transfer) { + int ret;struct spi_imx_data *spi_imx =spi_controller_get_devdata (spi->controller); -spi_imx_setupxfer (spi, transfer); + ret =spi_imx_setupxfer (spi, transfer); +if (ret <0 ) +return ret; transfer->effective_speed_hz = spi_imx->spi_bus_clk;/* flush rxfifo before transfer */--
2.47.2
Mark Brown
maintainerQuoted 14 lines · Tamura Dai
Add check for the return value of
spi_imx_setupxfer().spi_imx->rxandspi_imx->txfunction pointer can be NULL whenspi_imx_setupxfer()return error, and make NULL pointer dereference.Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 Call trace: 0x0 spi_imx_pio_transfer+0x50/0xd8 spi_imx_transfer_one+0x18c/0x858 spi_transfer_one_message+0x43c/0x790 __spi_pump_transfer_message+0x238/0x5d4 __spi_sync+0x2b0/0x454 spi_write_then_read+0x11c/0x200
Quoted 1 line
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[1/1] spi: spi-imx: Add check for spi_imx_setupxfer()
commit: 951a04ab3a2db4029debfa48d380ef834b93207e
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark