Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1700174
| From | Boris Brezillon <boris.brezillon@free-electrons.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] mtd: nand: sunxi: fix potential divide-by-zero error |
| Date | 2017-07-31 18:30 +0200 |
| Message-ID | <u9lJU-8uS-23@gated-at.bofh.it> (permalink) |
| References | <u8dlo-4dP-15@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Fri, 28 Jul 2017 14:22:57 +0100
Bryan O'Donoghue <pure.logic@nexus-software.ie> wrote:
> 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.
Applied to nand/fixes.
Thanks,
Boris
>
> Fixes: 2d43457f79e4 ("mtd: nand: sunxi: fix EDO mode selection")
>
> Signed-off-by: Bryan O'Donoghue <pure.logic@nexus-software.ie>
> ---
> drivers/mtd/nand/sunxi_nand.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
> index d0b6f8f..6abd142 100644
> --- a/drivers/mtd/nand/sunxi_nand.c
> +++ b/drivers/mtd/nand/sunxi_nand.c
> @@ -1728,6 +1728,10 @@ static int sunxi_nfc_setup_data_interface(struct mtd_info *mtd, int csline,
> */
> chip->clk_rate = NSEC_PER_SEC / min_clk_period;
> real_clk_rate = clk_round_rate(nfc->mod_clk, chip->clk_rate);
> + if (real_clk_rate <= 0) {
> + dev_err(nfc->dev, "Unable to round clk %lu\n", chip->clk_rate);
> + return -EINVAL;
> + }
>
> /*
> * ONFI specification 3.1, paragraph 4.15.2 dictates that EDO data
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH] mtd: nand: sunxi: fix potential divide-by-zero error Bryan O'Donoghue <pure.logic@nexus-software.ie> - 2017-07-28 15:20 +0200 Re: [PATCH] mtd: nand: sunxi: fix potential divide-by-zero error Boris Brezillon <boris.brezillon@free-electrons.com> - 2017-07-31 18:30 +0200
csiph-web