]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
power: supply: da9150-fg: remove VLA usage
authorGustavo A. R. Silva <gustavo@embeddedor.com>
Fri, 9 Mar 2018 18:27:08 +0000 (12:27 -0600)
committerSebastian Reichel <sre@kernel.org>
Mon, 12 Mar 2018 13:34:52 +0000 (14:34 +0100)
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>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
drivers/power/supply/da9150-fg.c

index 8b8ce978656a53fbde3800ab10b59cf3be3a4962..1e2e5b0520c913867bd852a8a57ae51108bc4870 100644 (file)
@@ -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;