From: Laura Abbott <labbott@redhat.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Kees Cook <keescook@chromium.org>, Lukas Wunner <lukas@wunner.de>,
"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
kernel-hardening@lists.openwall.com,
Rasmus Villemoes <linux@rasmusvillemoes.dk>
Subject: Re: [PATCHv3] gpio: Remove VLA from gpiolib
Date: Wed, 4 Apr 2018 11:31:41 -0700 [thread overview]
Message-ID: <2c191bd2-9df5-ecc1-1bf3-5ad19bea9138@redhat.com> (raw)
In-Reply-To: <CAHp75VdZOiJgzt3nhdeqwTXC=jsbndLWOV3eF_XmgFU-eHjYSg@mail.gmail.com>
On 03/30/2018 07:33 AM, Andy Shevchenko wrote:
> On Wed, Mar 28, 2018 at 9:18 PM, Laura Abbott <labbott@redhat.com> wrote:
>> The new challenge is to remove VLAs from the kernel
>> (see https://lkml.org/lkml/2018/3/7/621) to eventually
>> turn on -Wvla.
>>
>> Using a kmalloc array is the easy way to fix this but kmalloc is still
>> more expensive than stack allocation. Introduce a fast path with a
>> fixed size stack array to cover most chip with gpios below some fixed
>> amount. The slow path dynamically allocates an array to cover those
>> chips with a large number of gpios.
>
>> + ret = gpiod_set_array_value_complex(false,
>> true,
>> lh->numdescs,
>> lh->descs,
>> vals);
>> + if (ret)
>> + return ret;
>> +
>> return 0;
>
> Can't we
>
> return gpiod_set_array_value_complex(); ?
>
>
Yeah I'll clean that up for v4.
>> + slowpath = kcalloc(2 * BITS_TO_LONGS(chip->ngpio),
>> + sizeof(*slowpath),
>> + can_sleep ? GFP_KERNEL : GFP_ATOMIC);
>
>
>> + if (slowpath)
>> + kfree(slowpath);
>
>> + if (slowpath)
>> + kfree(slowpath);
>
> Since slowpath is a pointer, conditionals above are redundant.
>
>> + slowpath = kcalloc(2 * BITS_TO_LONGS(chip->ngpio),
>> + sizeof(*slowpath),
>> + can_sleep ? GFP_KERNEL : GFP_ATOMIC);
>
>> + if (slowpath)
>> + kfree(slowpath);
>
> Ditto.
>
This was caught by a coccinelle script via 0-day but I think the request
was to not do it. I'll add a comment explaining why we are going against
style.
Thanks,
Laura
next prev parent reply other threads:[~2018-04-04 18:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-28 18:18 [PATCHv3] gpio: Remove VLA from gpiolib Laura Abbott
2018-03-29 14:25 ` Lukas Wunner
2018-03-30 14:33 ` Andy Shevchenko
2018-04-04 18:31 ` Laura Abbott [this message]
2018-04-05 7:41 ` Rasmus Villemoes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2c191bd2-9df5-ecc1-1bf3-5ad19bea9138@redhat.com \
--to=labbott@redhat.com \
--cc=andy.shevchenko@gmail.com \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=lukas@wunner.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).