[U-Boot] [PATCH] spi: kirkwood: avoid divide by zero crash
Jagan Teki
jagannadh.teki at gmail.com
Fri Nov 10 06:22:16 UTC 2017
On Thu, Nov 9, 2017 at 5:09 PM, Baruch Siach <baruch at tkos.co.il> wrote:
> Calling .set_speed with zero speed is definitely a bug. Return an error value
> to handle that gracefully instead of crashing.
>
> Signed-off-by: Baruch Siach <baruch at tkos.co.il>
> ---
> drivers/spi/kirkwood_spi.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c
> index 0c6bd295cde9..9a27ac36822e 100644
> --- a/drivers/spi/kirkwood_spi.c
> +++ b/drivers/spi/kirkwood_spi.c
> @@ -257,6 +257,8 @@ static int mvebu_spi_set_speed(struct udevice *bus, uint hz)
> struct kwspi_registers *reg = plat->spireg;
> u32 data;
>
> + if (hz == 0)
> + return -EINVAL;
This isn't true, if hz 0 we should go with minimum divizer, usually
tclk we can get it from dts as plat->frequency and check the same with
speed to get the final speed.
thanks!
--
Jagan Teki
Free Software Engineer | www.openedev.com
U-Boot, Linux | Upstream Maintainer
Hyderabad, India.
More information about the U-Boot
mailing list