spi: spidev: prevent spidev->speed_hz from being zero
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 25 Jan 2022 06:52:02 +0000 (09:52 +0300)
committerMark Brown <broonie@kernel.org>
Tue, 8 Feb 2022 13:40:16 +0000 (13:40 +0000)
commit833026ad56f76d1a1035d6511fd5aeed308465fd
treef8b134ab79eb7f53f6c434d5a0cd4ec153f5f43f
parent4e28b22225e3a8b7f1bd3e093301802a2238071a
spi: spidev: prevent spidev->speed_hz from being zero

A zero value for spi->max_speed_hz or spidev->speed_hz does not make
sense and trying to set that can lead to divide by zero crashes in
a some of the drivers.

drivers/spi/spi-s3c64xx.c:874 s3c64xx_spi_setup() error: potential divide by zero bug '/ spi->max_speed_hz'.
drivers/spi/spi-fsl-dspi.c:613 hz_to_spi_baud() error: potential divide by zero bug '/ speed_hz'.
drivers/spi/spi-xlp.c:146 xlp_spi_setup() error: potential divide by zero bug '/ (spi->max_speed_hz)'.
drivers/spi/spi-orion.c:162 orion_spi_baudrate_set() error: potential divide by zero bug '/ speed'.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20220125065202.GA8807@kili
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spidev.c