Return -1 in raid_check and raid_scan when block size is 0

This commit is contained in:
Andrea Mazzoleni 2026-08-24 22:11:52 +02:00
parent 46a09a380a
commit e43bdda22b

View file

@ -138,6 +138,9 @@ int raid_check(int nr, int *ir, int nd, int np, size_t size, void **v)
BUG_ON(nr > 0 && ir[0] < 0);
BUG_ON(nr > 0 && ir[nr - 1] >= nd + np);
if (size == 0)
return -1;
/* count failed data disk */
rd = 0;
while (rd < nr && ir[rd] < nd)
@ -178,6 +181,9 @@ int raid_scan(int *ir, int nd, int np, size_t size, void **v)
BUG_ON(v == 0);
BUG_ON(np > 1 && ir == 0);
if (size == 0)
return -1;
/* check the special case of no failure */
if (np != 0 && raid_check(0, 0, nd, np, size, v) == 0)
return 0;