From e43bdda22b64719c142474a54ddbf58c3e3ad702 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Mon, 24 Aug 2026 22:11:52 +0200 Subject: [PATCH] Return -1 in raid_check and raid_scan when block size is 0 --- raid/check.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/raid/check.c b/raid/check.c index fd519f82..89c03c91 100644 --- a/raid/check.c +++ b/raid/check.c @@ -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;