]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
powerpc/prom: Remove VLA in prom_check_platform_support()
authorSuraj Jitindar Singh <sjitindarsingh@gmail.com>
Wed, 5 Sep 2018 02:09:50 +0000 (12:09 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 19 Sep 2018 12:08:12 +0000 (22:08 +1000)
In prom_check_platform_support() we retrieve and parse the
"ibm,arch-vec-5-platform-support" property of the chosen node.
Currently we use a variable length array however to avoid this use an
array of constant length 8.

This property is used to indicate the supported options of vector 5
bytes 23-26 of the ibm,architecture.vec node. Each of these options
is a pair of bytes, thus for 4 options we have a max length of 8 bytes.

Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/kernel/prom_init.c

index 9b38a2e5dd3576cd5023093e2655c4d6f6835a9d..1af453a61991515c922e695d0aafee76b29cb991 100644 (file)
@@ -1131,12 +1131,15 @@ static void __init prom_check_platform_support(void)
                                       "ibm,arch-vec-5-platform-support");
        if (prop_len > 1) {
                int i;
-               u8 vec[prop_len];
+               u8 vec[8];
                prom_debug("Found ibm,arch-vec-5-platform-support, len: %d\n",
                           prop_len);
+               if (prop_len > sizeof(vec))
+                       prom_printf("WARNING: ibm,arch-vec-5-platform-support longer than expected (len: %d)\n",
+                                   prop_len);
                prom_getprop(prom.chosen, "ibm,arch-vec-5-platform-support",
                             &vec, sizeof(vec));
-               for (i = 0; i < prop_len; i += 2) {
+               for (i = 0; i < sizeof(vec); i += 2) {
                        prom_debug("%d: index = 0x%x val = 0x%x\n", i / 2
                                                                  , vec[i]
                                                                  , vec[i + 1]);