All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] clk:Fix divide-by-zero in divider_ro_round_rate_parent
@ 2019-03-30  2:31 nixiaoming
  2019-03-30  9:44 ` Mukesh Ojha
  0 siblings, 1 reply; 3+ messages in thread
From: nixiaoming @ 2019-03-30  2:31 UTC (permalink / raw)
  To: jbrunet, mturquette, sboyd, soren.brinkmann, nixiaoming, mojha
  Cc: linux-clk, linux-kernel

In the function divider_recalc_rate() The judgment of the return value of
_get_div() indicates that the return value of _get_div() may be 0.
In order to avoid the divide-by-zero error, add check the return value
of _get_div() in the divider_ro_round_rate_parent()

Signed-off-by: nixiaoming <nixiaoming@huawei.com>
---
 drivers/clk/clk-divider.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index e5a1726..f4bf7a4 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -347,6 +347,9 @@ long divider_ro_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent,
 	int div;
 
 	div = _get_div(table, val, flags, width);
+	/* avoid divide-by-zero */
+	if (!div)
+		return -EINVAL;
 
 	/* Even a read-only clock can propagate a rate change */
 	if (clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) {
-- 
1.8.5.6


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 1/2] clk:Fix divide-by-zero in divider_ro_round_rate_parent
  2019-03-30  2:31 [PATCH v2 1/2] clk:Fix divide-by-zero in divider_ro_round_rate_parent nixiaoming
@ 2019-03-30  9:44 ` Mukesh Ojha
  2019-03-30 13:40   ` Nixiaoming
  0 siblings, 1 reply; 3+ messages in thread
From: Mukesh Ojha @ 2019-03-30  9:44 UTC (permalink / raw)
  To: nixiaoming, jbrunet, mturquette, sboyd, soren.brinkmann
  Cc: linux-clk, linux-kernel


On 3/30/2019 8:01 AM, nixiaoming wrote:
> In the function divider_recalc_rate() The judgment of the return value of
> _get_div() indicates that the return value of _get_div() may be 0.

s/may be/can be


> In order to avoid the divide-by-zero error, add check the return values.
s/add check the/add check for

> of _get_div() in the divider_ro_round_rate_parent()
>
> Signed-off-by: nixiaoming <nixiaoming@huawei.com>


Please fix the commit text.
Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>

Cheers,
-Mukesh

> ---
>   drivers/clk/clk-divider.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
> index e5a1726..f4bf7a4 100644
> --- a/drivers/clk/clk-divider.c
> +++ b/drivers/clk/clk-divider.c
> @@ -347,6 +347,9 @@ long divider_ro_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent,
>   	int div;
>   
>   	div = _get_div(table, val, flags, width);
> +	/* avoid divide-by-zero */
> +	if (!div)
> +		return -EINVAL;
>   
>   	/* Even a read-only clock can propagate a rate change */
>   	if (clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) {

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH v2 1/2] clk:Fix divide-by-zero in divider_ro_round_rate_parent
  2019-03-30  9:44 ` Mukesh Ojha
@ 2019-03-30 13:40   ` Nixiaoming
  0 siblings, 0 replies; 3+ messages in thread
From: Nixiaoming @ 2019-03-30 13:40 UTC (permalink / raw)
  To: Mukesh Ojha, jbrunet, mturquette, sboyd, soren.brinkmann
  Cc: linux-clk, linux-kernel

On 3/30/2019 5:44 PM, Mukesh Ojha wrote:
>On 3/30/2019 8:01 AM, nixiaoming wrote:
>> In the function divider_recalc_rate() The judgment of the return value of
>> _get_div() indicates that the return value of _get_div() may be 0.
>
>s/may be/can be

Thank you for your comments.
I will fix it in a later patch.
>
>> In order to avoid the divide-by-zero error, add check the return values.
>s/add check the/add check for
>
Thank you for your comments.
I will fix it in a later patch.

>> of _get_div() in the divider_ro_round_rate_parent()
>>
>> Signed-off-by: nixiaoming <nixiaoming@huawei.com>
>
>
>Please fix the commit text.
>Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>
>
>Cheers,
>-Mukesh
>

Thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-03-30 13:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-30  2:31 [PATCH v2 1/2] clk:Fix divide-by-zero in divider_ro_round_rate_parent nixiaoming
2019-03-30  9:44 ` Mukesh Ojha
2019-03-30 13:40   ` Nixiaoming

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.