Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Thu, 8 Mar 2018 22:58:13 -0600
From: "Gustavo A. R. Silva" <>
To: Support Opensource <>,
	Sebastian Reichel <>
	Kees Cook <>,
	"Gustavo A. R. Silva" <>
Subject: [PATCH] power: supply: da9150-fg: remove VLA usage

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:

Signed-off-by: Gustavo A. R. Silva <>
 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];
 	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_BYTE_SIZE];
 	u8 write_addr;
 	int i;

Powered by blists - more mailing lists

Your e-mail address:

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.