Fix raid_selftest() parity bounds and dispatch in Vandermonde mode

This commit is contained in:
Andrea Mazzoleni 2026-08-20 20:38:19 +02:00
parent fa9a5ac7fa
commit 52ea1bd035
3 changed files with 42 additions and 7 deletions

View file

@ -564,11 +564,18 @@ int raid_selftest(void)
int ir[RAID_PARITY_MAX];
int ip[RAID_PARITY_MAX];
int i, np;
int np_max;
int ret = 0;
/* ensure to have enough space for data */
BUG_ON(nd * size > 65536);
/* vandermonde mode only supports up to 3 parity rows */
if (raid_mode_active == RAID_MODE_VANDERMONDE_RAID)
np_max = 3;
else
np_max = RAID_PARITY_MAX;
v = raid_malloc_vector(nv, size, &v_alloc);
if (!v) {
/* LCOV_EXCL_START */
@ -584,14 +591,14 @@ int raid_selftest(void)
ref[i] = ((uint8_t *)raid_gfmul) + size * i;
/* setup reference parity */
for (i = 0; i < RAID_PARITY_MAX; ++i)
for (i = 0; i < np_max; ++i)
ref[nd + i] = v[nd + RAID_PARITY_MAX + i];
/* compute reference parity */
raid_gen_ref(nd, RAID_PARITY_MAX, size, ref);
raid_gen_ref(nd, np_max, size, ref);
/* test for each parity level */
for (np = 1; np <= RAID_PARITY_MAX; ++np) {
for (np = 1; np <= np_max; ++np) {
/* test parity generation */
ret = raid_test_par(nd, np, size, v, ref);
if (ret != 0) {