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] [day] [month] [year] [list]
Message-ID: <d58eeee5-e47d-4e2b-9b49-15f798c305ed@xilinx.com>
Date:   Wed, 19 May 2021 19:49:03 -0700
From:   Lizhi Hou <lizhi.hou@...inx.com>
To:     Tom Rix <trix@...hat.com>, Lizhi Hou <lizhi.hou@...inx.com>,
        <linux-kernel@...r.kernel.org>
CC:     <linux-fpga@...r.kernel.org>, <maxz@...inx.com>,
        <sonal.santan@...inx.com>, <yliu@...inx.com>,
        <michal.simek@...inx.com>, <stefanos@...inx.com>,
        <devicetree@...r.kernel.org>, <mdf@...nel.org>, <robh@...nel.org>,
        Max Zhen <max.zhen@...inx.com>
Subject: Re: [PATCH V6 XRT Alveo 16/20] fpga: xrt: clock driver



On 05/13/2021 08:48 AM, Tom Rix wrote:
>
>
>> +
>> +static int get_freq(struct clock *clock, u16 *freq)
>> +{
>
>> +
>> +     /*
>> +      * Multiply both numerator (mul0) and the denominator (div1) with
>> +      * 1000 to account for fractional portion of divider
>> +      */
>> +
>> +     div1 *= 1000;
>> +     div1 += div_frac1;
>> +     div0 *= div1;
>> +     mul0 *= 1000;
>> +     if (div0 == 0) {
>> +             CLOCK_ERR(clock, "clockwiz 0 divider");
>
> This prevents a divide by zero, but returns 0 without setting freq
>
> A -EINVAL should be returned or freq initialized to some default value
Sure.
>
>> +             return 0;
>> +     }
>> +
>> +     input = mul0 * 100;
>> +     do_div(input, div0);
>> +     *freq = (u16)input;
>> +
>> +     return 0;
>> +}
>> +
>>
>> +
>> +static int clock_verify_freq(struct clock *clock)
>> +{
>> +     u32 lookup_freq, clock_freq_counter, request_in_khz, tolerance;
>> +     int err = 0;
>> +     u16 freq;
>> +
>> +     mutex_lock(&clock->clock_lock);
>> +
>> +     err = get_freq(clock, &freq);
>> +     if (err) {
>> +             xrt_err(clock->xdev, "get freq failed, %d", err);
>> +             goto end;
>> +     }
>> +
>> +     err = get_freq_counter(clock, &clock_freq_counter);
>> +     if (err) {
>> +             xrt_err(clock->xdev, "get freq counter failed, %d", err);
>> +             goto end;
>> +     }
>> +
>> +     lookup_freq = find_matching_freq(freq, frequency_table,
>> + ARRAY_SIZE(frequency_table));
>
> I am running v6 through clang's static analyzer, it shows a problem here
>
> drivers/fpga/xrt/lib/xleaf/clock.c:474:16: warning: 1st function call
> argument is an uninitialized value
>         lookup_freq = find_matching_freq(freq, frequency_table,
>                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> See problem with get_freq above
Sure.

Thanks,
Lizhi
>
> Tom
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ