]> git.baikalelectronics.ru Git - kernel.git/commit
mtd: nand: sunxi: fix potential divide-by-zero error
authorBryan O'Donoghue <pure.logic@nexus-software.ie>
Fri, 28 Jul 2017 13:22:57 +0000 (14:22 +0100)
committerBoris Brezillon <boris.brezillon@free-electrons.com>
Wed, 2 Aug 2017 08:26:40 +0000 (10:26 +0200)
commit2cd7c07b6f901e6e2835c0ab4d7fca0fe89ecd64
tree0e2d8503a9d657df9a5fed39946d07dde81e1556
parent6b882e16ecaaa309b66ea296bd5725cf9cd42d0e
mtd: nand: sunxi: fix potential divide-by-zero error

clk_round_rate() can return <= 0. Currently the value returned by
clk_round_rate() is used directly for a division. This patch introduces a
guard to ensure a divide-by-zero or a divide by a negative number for that
matter can't happen by bugging out returning -EINVAL if clk_round_rate()
returns <= 0.

Fixes: 9f1fd1901186 ("mtd: nand: sunxi: fix EDO mode selection")
Signed-off-by: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
drivers/mtd/nand/sunxi_nand.c