]> git.baikalelectronics.ru Git - uboot.git/commit
mtd: cqspi: Fix division by zero
authorMarek Vasut <marex@denx.de>
Tue, 14 Sep 2021 03:21:48 +0000 (05:21 +0200)
committerTom Rini <trini@konsulko.com>
Mon, 4 Oct 2021 12:51:14 +0000 (08:51 -0400)
commit4611239aad0a18256eda0389f9dacf04de41ea9a
treecbc73f184158baab21e6f5cedce971d4c28b3667
parent6f8029a1a227d490f38f7ac55bacf023f4abe53e
mtd: cqspi: Fix division by zero

Both dummy.nbytes and dummy.buswidth may be zero. By not checking
the later, it is possible to trigger division by zero and a crash.
This does happen with tiny SPI NOR framework in SPL. Fix this by
adding the check and returning zero dummy bytes in such a case.

Fixes: d0ac127323d ("spi: cadence-qspi: Add support for octal DTR flashes")
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Jagan Teki <jagan@amarulasolutions.com>
Cc: Vignesh R <vigneshr@ti.com>
Cc: Pratyush Yadav <p.yadav@ti.com>
[trini: Drop Pratyush's RB as his requested changes weren't made as
        Marek disagreed]
drivers/spi/cadence_qspi_apb.c