From 306f84768928d5d8dd83cdbf712a315c9b2182a9 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Mon, 24 Aug 2026 21:42:22 +0200 Subject: [PATCH] Reset global zero buffer with raid_zero(0) in raid_selftest cleanup --- raid/module.c | 6 ++++++ raid/raid.h | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/raid/module.c b/raid/module.c index 3f244ef6..c5fa05b4 100644 --- a/raid/module.c +++ b/raid/module.c @@ -779,6 +779,12 @@ int raid_selftest(void) ret = 0; bail: + /* + * Reset the global zero buffer so that it does not point to + * the deallocated memory. + */ + raid_zero(0); + free(v); free(v_alloc); diff --git a/raid/raid.h b/raid/raid.h index b8012797..459adeba 100644 --- a/raid/raid.h +++ b/raid/raid.h @@ -161,6 +161,10 @@ int raid_mode(int mode); * The test modifies global RAID state and must not be called concurrently * with any other RAID function. * + * The test resets the zero buffer to 0 via raid_zero(0) upon completion. + * A valid zero buffer must be set with raid_zero() afterwards before calling + * recovery functions (raid_rec(), raid_data()). + * * It returns 0 on success. */ int raid_selftest(void);