lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2882780e-ac45-c5e7-26fd-a1882a67113a@codeaurora.org>
Date:   Fri, 29 Mar 2019 18:11:34 +0530
From:   Mukesh Ojha <mojha@...eaurora.org>
To:     nixiaoming <nixiaoming@...wei.com>, mturquette@...libre.com,
        sboyd@...nel.org, chao.xie@...vell.com
Cc:     linux-clk@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] clk:mmp: clk-mix.c fix divide-by-zero


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@...wei.com>

Fix the below minor comments..
Otherwise things look good..you can take mine
Reviewed-by: Mukesh Ojha <mojha@...eaurora.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;
>   }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ