From: "Gustavo A. R. Silva" <garsilva@embeddedor.com>
To: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>,
"Gustavo A. R. Silva" <gustavo@embeddedor.com>,
Support Opensource <Support.Opensource@diasemi.com>,
Sebastian Reichel <sre@kernel.org>
Cc: "linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"kernel-hardening@lists.openwall.com"
<kernel-hardening@lists.openwall.com>,
Kees Cook <keescook@chromium.org>
Subject: Re: [PATCH] power: supply: da9150-fg: remove VLA usage
Date: Fri, 9 Mar 2018 11:55:40 -0600 [thread overview]
Message-ID: <b657eeff-ba9d-c40c-24f3-b971c893b6c3@embeddedor.com> (raw)
In-Reply-To: <2E89032DDAA8B9408CB92943514A0337014C1D771E@SW-EX-MBX01.diasemi.com>
On 03/09/2018 05:36 AM, Adam Thomson wrote:
> On 09 March 2018 04:58, Gustavo A. R. Silva wrote:
>
>> In preparation to enabling -Wvla, remove VLA usage and replace it
>> with fixed-length arrays.
>>
>> It seems that the length of array 'buf' will not exceed
>> DA9150_QIF_SHORT_SIZE bytes (2 bytes). But a fixed length
>> of DA9150_QIF_BYTE_SIZE bytes (8 bytes) was chosen in case
>> this change in the future.
>>
>> Fixed as part of the directive to remove all VLAs from
>> the kernel: https://lkml.org/lkml/2018/3/7/621
>>
>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
>> ---
>> drivers/power/supply/da9150-fg.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/power/supply/da9150-fg.c b/drivers/power/supply/da9150-fg.c
>> index 8b8ce97..96893be 100644
>> --- a/drivers/power/supply/da9150-fg.c
>> +++ b/drivers/power/supply/da9150-fg.c
>> @@ -92,7 +92,7 @@ struct da9150_fg {
>> static u32 da9150_fg_read_attr(struct da9150_fg *fg, u8 code, u8 size)
>>
>> {
>> - u8 buf[size];
>> + u8 buf[DA9150_QIF_BYTE_SIZE];
>
> You can use DA9150_QIF_LONG_SIZE as that's the biggest size of an attribute
> which can be accessed. This will also save a little space.
>
I got it. I'll send v2 shortly.
Thanks for the feedback, Adam.
--
Gustavo
prev parent reply other threads:[~2018-03-09 17:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-09 4:58 [PATCH] power: supply: da9150-fg: remove VLA usage Gustavo A. R. Silva
2018-03-09 11:36 ` Adam Thomson
2018-03-09 17:55 ` Gustavo A. R. Silva [this message]
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=b657eeff-ba9d-c40c-24f3-b971c893b6c3@embeddedor.com \
--to=garsilva@embeddedor.com \
--cc=Adam.Thomson.Opensource@diasemi.com \
--cc=Support.Opensource@diasemi.com \
--cc=gustavo@embeddedor.com \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=sre@kernel.org \
/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