* [PATCH] clk:Fix divide by 0 error in divider_ro_round_rate_parent
@ 2019-03-29 9:05 nixiaoming
2019-03-29 22:42 ` Stephen Boyd
0 siblings, 1 reply; 3+ messages in thread
From: nixiaoming @ 2019-03-29 9:05 UTC (permalink / raw)
To: mturquette, sboyd, jbrunet, rnayak, soren.brinkmann, sboyd, nixiaoming
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 | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index e5a1726..0854e3e 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -347,6 +347,8 @@ long divider_ro_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent,
int div;
div = _get_div(table, val, flags, width);
+ if (!div) /* avoid divide-by-zero */
+ 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] clk:Fix divide by 0 error in divider_ro_round_rate_parent
2019-03-29 9:05 [PATCH] clk:Fix divide by 0 error in divider_ro_round_rate_parent nixiaoming
@ 2019-03-29 22:42 ` Stephen Boyd
2019-03-30 2:03 ` Nixiaoming
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Boyd @ 2019-03-29 22:42 UTC (permalink / raw)
To: jbrunet, mturquette, nixiaoming, rnayak, sboyd, soren.brinkmann
Cc: linux-clk, linux-kernel
Quoting nixiaoming (2019-03-29 02:05:24)
> In the function divider_recalc_rate The judgment of the return value of
Please write divider_recalc_rate() with parenthesis to show it's a
function.
> _get_div indicates that the return value of _get_div may be 0.
__get_div()
> 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>
Is this your name? nixiaoming? Or is it written some other way?
> ---
> drivers/clk/clk-divider.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
> index e5a1726..0854e3e 100644
> --- a/drivers/clk/clk-divider.c
> +++ b/drivers/clk/clk-divider.c
> @@ -347,6 +347,8 @@ long divider_ro_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent,
> int div;
>
> div = _get_div(table, val, flags, width);
> + if (!div) /* avoid divide-by-zero */
> + return -EINVAL;
How does _get_div() return 0? What is the value of 'flags' here when
this goes wrong?
>
> /* Even a read-only clock can propagate a rate change */
> if (clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) {
> --
> 1.8.5.6
>
Wow that's a 5 year old version of git!
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] clk:Fix divide by 0 error in divider_ro_round_rate_parent
2019-03-29 22:42 ` Stephen Boyd
@ 2019-03-30 2:03 ` Nixiaoming
0 siblings, 0 replies; 3+ messages in thread
From: Nixiaoming @ 2019-03-30 2:03 UTC (permalink / raw)
To: Stephen Boyd, jbrunet, mturquette, rnayak, sboyd, soren.brinkmann
Cc: linux-clk, linux-kernel
On 3/30/2019 6:42 AM Stephen Boyd wrote:
>Quoting nixiaoming (2019-03-29 02:05:24)
>> In the function divider_recalc_rate The judgment of the return value of
>
>Please write divider_recalc_rate() with parenthesis to show it's a
>function.
>
>> _get_div indicates that the return value of _get_div may be 0.
>
>__get_div()
Thank you for your guidance, I will correct it later in the patch.
>> 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>
>
>Is this your name? nixiaoming? Or is it written some other way?
Chinese name 倪小明
>> ---
>> drivers/clk/clk-divider.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
>> index e5a1726..0854e3e 100644
>> --- a/drivers/clk/clk-divider.c
>> +++ b/drivers/clk/clk-divider.c
>> @@ -347,6 +347,8 @@ long divider_ro_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent,
>> int div;
>>
>> div = _get_div(table, val, flags, width);
>> + if (!div) /* avoid divide-by-zero */
>> + return -EINVAL;
>
>How does _get_div() return 0? What is the value of 'flags' here when
>this goes wrong?
divider_ro_round_rate_parent() and divider_recalc_rate() are functions
of the EXPORT_SYMBOL_GPL attribute
If _get_div() can return 0 in the argument of divider_recalc_rate()
Then should be able to return 0 in divider_ro_round_rate_parent()
>
>>
>> /* Even a read-only clock can propagate a rate change */
>> if (clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) {
>> --
>> 1.8.5.6
>>
>
>Wow that's a 5 year old version of git!
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-03-30 2:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-29 9:05 [PATCH] clk:Fix divide by 0 error in divider_ro_round_rate_parent nixiaoming
2019-03-29 22:42 ` Stephen Boyd
2019-03-30 2:03 ` Nixiaoming
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).