From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Tamura Dai <kirinode0@gmail.com>,
Carlos Song <carlos.song@nxp.com>,
Mark Brown <broonie@kernel.org>, Sasha Levin <sashal@kernel.org>,
shawnguo@kernel.org, linux-spi@vger.kernel.org,
imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org
Subject: [PATCH AUTOSEL 6.1 12/12] spi: spi-imx: Add check for spi_imx_setupxfer()
Date: Mon, 21 Apr 2025 22:18:26 -0400 [thread overview]
Message-ID: <20250422021826.1941778-12-sashal@kernel.org> (raw)
In-Reply-To: <20250422021826.1941778-1-sashal@kernel.org>
From: Tamura Dai <kirinode0@gmail.com>
[ Upstream commit 951a04ab3a2db4029debfa48d380ef834b93207e ]
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
Signed-off-by: Tamura Dai <kirinode0@gmail.com>
Reviewed-by: Carlos Song <carlos.song@nxp.com>
Link: https://patch.msgid.link/20250417011700.14436-1-kirinode0@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/spi/spi-imx.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index df73a2c7120c9..13a6ebef01894 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -1605,10 +1605,13 @@ 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);
unsigned long hz_per_byte, byte_limit;
- 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.39.5
prev parent reply other threads:[~2025-04-22 2:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-22 2:18 [PATCH AUTOSEL 6.1 01/12] scsi: hisi_sas: Fix I/O errors caused by hardware port ID changes Sasha Levin
2025-04-22 2:18 ` [PATCH AUTOSEL 6.1 02/12] scsi: ufs: exynos: Ensure pre_link() executes before exynos_ufs_phy_init() Sasha Levin
2025-04-22 2:18 ` [PATCH AUTOSEL 6.1 03/12] scsi: pm80xx: Set phy_attached to zero when device is gone Sasha Levin
2025-04-22 2:18 ` [PATCH AUTOSEL 6.1 04/12] x86/i8253: Call clockevent_i8253_disable() with interrupts disabled Sasha Levin
2025-04-22 2:18 ` [PATCH AUTOSEL 6.1 05/12] loop: aio inherit the ioprio of original request Sasha Levin
2025-04-22 2:18 ` [PATCH AUTOSEL 6.1 06/12] spi: tegra210-quad: use WARN_ON_ONCE instead of WARN_ON for timeouts Sasha Levin
2025-04-22 2:18 ` [PATCH AUTOSEL 6.1 07/12] spi: tegra210-quad: add rate limiting and simplify timeout error message Sasha Levin
2025-04-22 2:18 ` [PATCH AUTOSEL 6.1 08/12] hardening: Disable GCC randstruct for COMPILE_TEST Sasha Levin
2025-04-22 2:18 ` [PATCH AUTOSEL 6.1 09/12] ubsan: Fix panic from test_ubsan_out_of_bounds Sasha Levin
2025-04-22 2:18 ` [PATCH AUTOSEL 6.1 10/12] md/raid1: Add check for missing source disk in process_checks() Sasha Levin
2025-04-22 2:18 ` [PATCH AUTOSEL 6.1 11/12] riscv: Avoid fortify warning in syscall_get_arguments() Sasha Levin
2025-04-22 2:18 ` Sasha Levin
2025-04-22 2:18 ` Sasha Levin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250422021826.1941778-12-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=broonie@kernel.org \
--cc=carlos.song@nxp.com \
--cc=imx@lists.linux.dev \
--cc=kirinode0@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=shawnguo@kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.