]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
ge: common: vpd_reader: fix errloc array size in verify_bch()
authorMd Shofiqul Islam <shofiqtest@gmail.com>
Sun, 5 Jul 2026 10:08:41 +0000 (13:08 +0300)
committerFabio Estevam <festevam@gmail.com>
Mon, 27 Jul 2026 14:29:56 +0000 (11:29 -0300)
errloc stores bit positions of errors returned by decode_bch().
The maximum number of correctable errors is ecc_bits, so errloc
must have ecc_bits entries.  The array was allocated with data_length
entries instead, which is the number of EEPROM data bytes -- orders
of magnitude larger than needed and incorrect.

Fixes: b418dfe16e62 ("board: ge: make VPD code common")
Signed-off-by: Md Shofiqul Islam <shofiqtest@gmail.com>
board/ge/common/vpd_reader.c

index 2422db38013942e55fc216473b4d3ddd5be2e4f7..b3f9e96615d7a33e2c94764fc8913a77ba381843 100644 (file)
@@ -66,7 +66,7 @@ static int verify_bch(int ecc_bits, unsigned int prim_poly, u8 *data,
                return -1;
        }
 
-       unsigned int *errloc = (unsigned int *)calloc(data_length,
+       unsigned int *errloc = (unsigned int *)calloc(ecc_bits,
                                                      sizeof(unsigned int));
        int errors = decode_bch(bch, data, data_length, ecc, NULL, NULL,
                                errloc);