* [PATCH v2] power: supply: da9150-fg: remove VLA usage
@ 2018-03-09 18:27 Gustavo A. R. Silva
2018-03-12 8:28 ` Adam Thomson
2018-03-12 13:41 ` Sebastian Reichel
0 siblings, 2 replies; 3+ messages in thread
From: Gustavo A. R. Silva @ 2018-03-09 18:27 UTC (permalink / raw)
To: Adam Thomson, Support Opensource, Sebastian Reichel
Cc: linux-pm, linux-kernel, kernel-hardening, Kees Cook, Gustavo A. R. Silva
In preparation to enabling -Wvla, remove VLA usage and replace it
with fixed-length arrays.
DA9150_QIF_LONG_SIZE (4 bytes) is the biggest size of an attribute which can
be accessed [1].
Fixed as part of the directive to remove all VLAs from
the kernel: https://lkml.org/lkml/2018/3/7/621
[1] https://marc.info/?l=kernel-hardening&m=152059600524753&w=2
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
Changes in v2:
- Use DA9150_QIF_LONG_SIZE instead of DA9150_QIF_BYTE_SIZE as the
maximum size for array 'buf'. Thanks to Adam Thomson for the
feedback on this.
- Update changelog based on Adam's comments.
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..7ea2188 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_LONG_SIZE];
u8 read_addr;
u32 res = 0;
int i;
@@ -111,7 +111,7 @@ static void da9150_fg_write_attr(struct da9150_fg *fg, u8 code, u8 size,
u32 val)
{
- u8 buf[size];
+ u8 buf[DA9150_QIF_LONG_SIZE];
u8 write_addr;
int i;
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH v2] power: supply: da9150-fg: remove VLA usage
2018-03-09 18:27 [PATCH v2] power: supply: da9150-fg: remove VLA usage Gustavo A. R. Silva
@ 2018-03-12 8:28 ` Adam Thomson
2018-03-12 13:41 ` Sebastian Reichel
1 sibling, 0 replies; 3+ messages in thread
From: Adam Thomson @ 2018-03-12 8:28 UTC (permalink / raw)
To: Gustavo A. R. Silva, Adam Thomson, Support Opensource, Sebastian Reichel
Cc: linux-pm, linux-kernel, kernel-hardening, Kees Cook, Gustavo A. R. Silva
On 09 March 2018 18:27, Gustavo A. R. Silva wrote:
> In preparation to enabling -Wvla, remove VLA usage and replace it
> with fixed-length arrays.
>
> DA9150_QIF_LONG_SIZE (4 bytes) is the biggest size of an attribute which can
> be accessed [1].
>
> Fixed as part of the directive to remove all VLAs from
> the kernel: https://lkml.org/lkml/2018/3/7/621
>
> [1] https://marc.info/?l=kernel-hardening&m=152059600524753&w=2
>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Acked-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> ---
> Changes in v2:
> - Use DA9150_QIF_LONG_SIZE instead of DA9150_QIF_BYTE_SIZE as the
> maximum size for array 'buf'. Thanks to Adam Thomson for the
> feedback on this.
> - Update changelog based on Adam's comments.
>
> 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..7ea2188 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_LONG_SIZE];
> u8 read_addr;
> u32 res = 0;
> int i;
> @@ -111,7 +111,7 @@ static void da9150_fg_write_attr(struct da9150_fg *fg, u8
> code, u8 size,
> u32 val)
>
> {
> - u8 buf[size];
> + u8 buf[DA9150_QIF_LONG_SIZE];
> u8 write_addr;
> int i;
>
> --
> 2.7.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] power: supply: da9150-fg: remove VLA usage
2018-03-09 18:27 [PATCH v2] power: supply: da9150-fg: remove VLA usage Gustavo A. R. Silva
2018-03-12 8:28 ` Adam Thomson
@ 2018-03-12 13:41 ` Sebastian Reichel
1 sibling, 0 replies; 3+ messages in thread
From: Sebastian Reichel @ 2018-03-12 13:41 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Adam Thomson, Support Opensource, linux-pm, linux-kernel,
kernel-hardening, Kees Cook, Gustavo A. R. Silva
[-- Attachment #1: Type: text/plain, Size: 1607 bytes --]
Hi,
On Fri, Mar 09, 2018 at 12:27:08PM -0600, Gustavo A. R. Silva wrote:
> In preparation to enabling -Wvla, remove VLA usage and replace it
> with fixed-length arrays.
>
> DA9150_QIF_LONG_SIZE (4 bytes) is the biggest size of an attribute which can
> be accessed [1].
>
> Fixed as part of the directive to remove all VLAs from
> the kernel: https://lkml.org/lkml/2018/3/7/621
>
> [1] https://marc.info/?l=kernel-hardening&m=152059600524753&w=2
>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
Thanks, queued to power-supply's for-next branch.
-- Sebastian
> Changes in v2:
> - Use DA9150_QIF_LONG_SIZE instead of DA9150_QIF_BYTE_SIZE as the
> maximum size for array 'buf'. Thanks to Adam Thomson for the
> feedback on this.
> - Update changelog based on Adam's comments.
>
> 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..7ea2188 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_LONG_SIZE];
> u8 read_addr;
> u32 res = 0;
> int i;
> @@ -111,7 +111,7 @@ static void da9150_fg_write_attr(struct da9150_fg *fg, u8 code, u8 size,
> u32 val)
>
> {
> - u8 buf[size];
> + u8 buf[DA9150_QIF_LONG_SIZE];
> u8 write_addr;
> int i;
>
> --
> 2.7.4
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-03-12 13:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-09 18:27 [PATCH v2] power: supply: da9150-fg: remove VLA usage Gustavo A. R. Silva
2018-03-12 8:28 ` Adam Thomson
2018-03-12 13:41 ` Sebastian Reichel
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).