From: Mukesh Ojha <mojha@codeaurora.org>
To: nixiaoming <nixiaoming@huawei.com>,
mturquette@baylibre.com, sboyd@kernel.org, chao.xie@marvell.com
Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] clk:mmp: clk-mix.c fix divide-by-zero
Date: Fri, 29 Mar 2019 18:11:34 +0530 [thread overview]
Message-ID: <2882780e-ac45-c5e7-26fd-a1882a67113a@codeaurora.org> (raw)
In-Reply-To: <1553859960-31501-1-git-send-email-nixiaoming@huawei.com>
On 3/29/2019 5:16 PM, nixiaoming wrote:
> The _get_div function has a branch with a return value of 0
> Add a check on the return value of _get_div to avoid divide-by-zero
>
> Signed-off-by: nixiaoming <nixiaoming@huawei.com>
Fix the below minor comments..
Otherwise things look good..you can take mine
Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>
after fixing it.
Cheers,
-Mukesh
> ---
> drivers/clk/mmp/clk-mix.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/clk/mmp/clk-mix.c b/drivers/clk/mmp/clk-mix.c
> index 90814b2..9d152c2 100644
> --- a/drivers/clk/mmp/clk-mix.c
> +++ b/drivers/clk/mmp/clk-mix.c
> @@ -245,6 +245,8 @@ static int mmp_clk_mix_determine_rate(struct clk_hw *hw,
> div_val_max = _get_maxdiv(mix);
> for (j = 0; j < div_val_max; j++) {
> div = _get_div(mix, j);
> + if (!div) /* avoid divide-by-zero */
Please move this comment at the top of the check.
> + continue;
> mix_rate = parent_rate / div;
> gap = abs(mix_rate - req->rate);
> if (!parent_best || gap < gap_best) {
> @@ -341,6 +343,8 @@ static unsigned long mmp_clk_mix_recalc_rate(struct clk_hw *hw,
> shift = mix->reg_info.shift_div;
>
> div = _get_div(mix, MMP_CLK_BITS_GET_VAL(mux_div, width, shift));
> + if (!div) /* avoid divide-by-zero */
ditto
> + return -EINVAL;
>
> return parent_rate / div;
> }
next prev parent reply other threads:[~2019-03-29 12:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-29 11:46 nixiaoming
2019-03-29 12:41 ` Mukesh Ojha [this message]
2019-03-29 22:48 ` Stephen Boyd
2019-03-30 2:20 ` Nixiaoming
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=2882780e-ac45-c5e7-26fd-a1882a67113a@codeaurora.org \
--to=mojha@codeaurora.org \
--cc=chao.xie@marvell.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=nixiaoming@huawei.com \
--cc=sboyd@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®