From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Cc: richard@nod.at, dwmw2@infradead.org, computersforpeace@gmail.com,
marek.vasut@gmail.com, cyrille.pitchen@wedev4u.fr,
maxime.ripard@free-electrons.com, wens@csie.org,
linux-mtd@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mtd: nand: sunxi: fix potential divide-by-zero error
Date: Mon, 31 Jul 2017 18:28:40 +0200 [thread overview]
Message-ID: <20170731182840.4cdca90d@bbrezillon> (raw)
In-Reply-To: <1501248177-575-1-git-send-email-pure.logic@nexus-software.ie>
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
WARNING: multiple messages have this Message-ID (diff)
From: boris.brezillon@free-electrons.com (Boris Brezillon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] mtd: nand: sunxi: fix potential divide-by-zero error
Date: Mon, 31 Jul 2017 18:28:40 +0200 [thread overview]
Message-ID: <20170731182840.4cdca90d@bbrezillon> (raw)
In-Reply-To: <1501248177-575-1-git-send-email-pure.logic@nexus-software.ie>
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
next prev parent reply other threads:[~2017-07-31 16:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-28 13:22 [PATCH] mtd: nand: sunxi: fix potential divide-by-zero error Bryan O'Donoghue
2017-07-28 13:22 ` Bryan O'Donoghue
2017-07-31 16:28 ` Boris Brezillon [this message]
2017-07-31 16:28 ` Boris Brezillon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170731182840.4cdca90d@bbrezillon \
--to=boris.brezillon@free-electrons.com \
--cc=computersforpeace@gmail.com \
--cc=cyrille.pitchen@wedev4u.fr \
--cc=dwmw2@infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.com \
--cc=maxime.ripard@free-electrons.com \
--cc=pure.logic@nexus-software.ie \
--cc=richard@nod.at \
--cc=wens@csie.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.