]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
soc: soc_ti_k3: fix revision array bounds checks
authorRasmus Villemoes <rasmus.villemoes@prevas.dk>
Fri, 24 Mar 2023 07:44:29 +0000 (08:44 +0100)
committerTom Rini <trini@konsulko.com>
Tue, 25 Apr 2023 19:31:27 +0000 (15:31 -0400)
If rev is equal to the array size, we'll access the array
one-past-the-end.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Bryan Brattlof <bb@ti.com>
drivers/soc/soc_ti_k3.c

index 42430d79a7ad6601fcd7e32d7fe35f0ae94bd270..b720131ae5df96e77a4f92a28cbe064c6592d83c 100644 (file)
@@ -70,12 +70,12 @@ static const char *get_rev_string(u32 idreg)
 
        switch (soc) {
        case JTAG_ID_PARTNO_J721E:
-               if (rev > ARRAY_SIZE(j721e_rev_string_map))
+               if (rev >= ARRAY_SIZE(j721e_rev_string_map))
                        goto bail;
                return j721e_rev_string_map[rev];
 
        default:
-               if (rev > ARRAY_SIZE(typical_rev_string_map))
+               if (rev >= ARRAY_SIZE(typical_rev_string_map))
                        goto bail;
                return typical_rev_string_map[rev];
        };