2023-05-05 06:54:34

by Clark Wang

[permalink] [raw]
Subject: [PATCH] spi: lpspi: run transfer speed_hz sanity check

Avoid config.speed_hz is 0 when it is a divisor.

Signed-off-by: Han Xu <[email protected]>
Signed-off-by: Clark Wang <[email protected]>
---
drivers/spi/spi-fsl-lpspi.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c
index 4b70038ceb6b..80f7367095ab 100644
--- a/drivers/spi/spi-fsl-lpspi.c
+++ b/drivers/spi/spi-fsl-lpspi.c
@@ -303,6 +303,12 @@ static int fsl_lpspi_set_bitrate(struct fsl_lpspi_data *fsl_lpspi)

perclk_rate = clk_get_rate(fsl_lpspi->clk_per);

+ if (!config.speed_hz) {
+ dev_err(fsl_lpspi->dev,
+ "error: the transmission speed provided is 0!\n");
+ return -EINVAL;
+ }
+
if (config.speed_hz > perclk_rate / 2) {
dev_err(fsl_lpspi->dev,
"per-clk should be at least two times of transfer speed");
--
2.34.1


2023-05-08 13:39:26

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH] spi: lpspi: run transfer speed_hz sanity check

On Fri, 05 May 2023 14:41:59 +0800, Clark Wang wrote:
> Avoid config.speed_hz is 0 when it is a divisor.
>
>

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: lpspi: run transfer speed_hz sanity check
commit: f571d9132e0657b4aae40a8ffe758224d1f41047

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