lkml.org 
[lkml]   [2019]   [Jul]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] hpet: Fix division by zero in hpet_time_div()
From
Date


On 2019/7/11 20:32, Arnd Bergmann wrote:
> On Thu, Jul 11, 2019 at 1:20 PM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>> The base value in do_div() called by hpet_time_div() is truncated from
>> unsigned long to uint32_t, resulting in a divide-by-zero exception.
>
> Good catch!
>
>> --- a/drivers/char/hpet.c
>> +++ b/drivers/char/hpet.c
>> @@ -567,7 +567,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
>> unsigned long long m;
>>
>> m = hpets->hp_tick_freq + (dis >> 1);
>> - do_div(m, dis);
>> + div64_ul(m, dis);
>> return (unsigned long)m;
>> }
>
> This still looks wrong to me: div64_ul() unlike do_div() does not
> modify its argument, so you have to assign the output like
>
> return div64_ul(m, dis);

right, should check div64_ul more carefully, will resend v2, thanks

>
> Arnd
>
>

\
 
 \ /
  Last update: 2019-07-11 15:21    [W:0.048 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site