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]
Date:   Tue, 27 Feb 2018 17:54:00 +0200
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Baolin Wang <baolin.wang@...aro.org>
Cc:     Linus Walleij <linus.walleij@...aro.org>,
        Rob Herring <robh+dt@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        devicetree <devicetree@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        "open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
        Mark Brown <broonie@...nel.org>
Subject: Re: [PATCH v2 3/3] gpio: Add Spreadtrum PMIC EIC driver support

On Tue, Feb 27, 2018 at 4:35 AM, Baolin Wang <baolin.wang@...aro.org> wrote:
> On 26 February 2018 at 20:02, Andy Shevchenko <andy.shevchenko@...il.com> wrote:
>> On Mon, Feb 26, 2018 at 5:01 AM, Baolin Wang <baolin.wang@...aro.org> wrote:
>>> On 25 February 2018 at 20:19, Andy Shevchenko <andy.shevchenko@...il.com> wrote:

>>>>> +       for (n = 0; n < chip->ngpio; n++) {
>>>>> +               if (!(BIT(n) & val))
>>>>
>>>> for_each_set_bit().
>>>>
>>>> At some point you may need just to go across lib/ in the kernel and
>>>> see what we have there.
>>>
>>> I've considered the for_each_set_bit(), it need one 'unsigned long'
>>> type parameter, but we get the value from regmap is 'u32' type. So we
>>> need one extra conversion from 'u32' to 'unsigned long' like:
>>>
>>> unsigned long reg = val;
>>>
>>> for_each_set_bit(n, &reg, chip->ngpio) {
>>>         .......
>>> }
>>>
>>> If you like this conversion, then I can change to use
>>> for_each_set_bit(). Thanks.
>>
>> Wouldn't it work like
>>
>> unsigned long val;
>>
>> ...regmap_read(..., &val);
>>
>> ?
>
> It can not work, regmap_read() expects 'unsigned int *'.

Ah, OK, than the temporary variable is a left approach.

> But I can
> convert it like this:
>
> for_each_set_bit(n, (unsigned long *)&val, chip->ngpio) {
>          .......
> }

No, this is a boilerplate for static analyzers and definitely UB.

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ