]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
arm64: versal2: Fix buffer overflow in soc_name_decode
authorFrancois Berder <fberder@outlook.fr>
Thu, 21 May 2026 13:05:44 +0000 (15:05 +0200)
committerMichal Simek <michal.simek@amd.com>
Mon, 25 May 2026 13:14:05 +0000 (15:14 +0200)
The size of name buffer was not computed correctly.
The suffix format is "--rel.-el" (9 chars instead of 6),
and the longest platform name is "emu-mmd" (7 chars instead of 4).
Fix comment and name size.

Fixes: 40f5046c221a ("arm64: versal2: Add support for AMD Versal Gen 2")
Signed-off-by: Francois Berder <fberder@outlook.fr>
Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/BESP194MB280513B376D54A815F3FD507DA0E2@BESP194MB2805.EURP194.PROD.OUTLOOK.COM
board/amd/versal2/board.c

index d94c1494d5397e27a1317b436035ae6d5ad91030..81daba1c5ef69cafbae5abcec3cc057326fdb56a 100644 (file)
@@ -81,12 +81,13 @@ char *soc_name_decode(void)
        }
 
        /*
-        * --rev. are 6 chars
-        * max platform name is qemu which is 4 chars
+        * --rev.-el are 9 chars
+        * max platform name is emu-mmd which is 7 chars
         * platform version number are 1+1
-        * Plus 1 char for \n
+        * el is 1 char
+        * Plus 1 char for NULL byte
         */
-       name = calloc(1, strlen(CONFIG_SYS_BOARD) + 13);
+       name = calloc(1, strlen(CONFIG_SYS_BOARD) + 20);
        if (!name)
                return NULL;