aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
authorChristoph Hellwig <hch@lst.de>2026-06-22 18:07:52 +0200
committerJens Axboe <axboe@kernel.dk>2026-06-22 15:55:11 -0600
commit214cdae69dba9bb1fc0b517b7fb97bab385a2e3a (patch)
tree1f243cbaf75be6c72aa19d879954277e13232de1 /block
parentd5b58fbb2fd7ac25fcd7e1c14730f998a90b0322 (diff)
downloadath-214cdae69dba9bb1fc0b517b7fb97bab385a2e3a.tar.gz
block: fix incorrect error injection static key decrement
Only decrement the static key when we had items and thus it was incremented before. Fixes: e8dcf2d142bd ("block: add configurable error injection") Reported-by: Damien Le Moal <dlemoal@kernel.org> Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://patch.msgid.link/20260622160752.1552516-1-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r--block/error-injection.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/block/error-injection.c b/block/error-injection.c
index d24c90e9a25f9..cfb83138960c8 100644
--- a/block/error-injection.c
+++ b/block/error-injection.c
@@ -120,13 +120,13 @@ static void error_inject_removeall(struct gendisk *disk)
struct blk_error_inject *inj;
mutex_lock(&disk->error_injection_lock);
- clear_bit(GD_ERROR_INJECT, &disk->state);
+ if (test_and_clear_bit(GD_ERROR_INJECT, &disk->state))
+ static_branch_dec(&blk_error_injection_enabled);
while ((inj = list_first_entry_or_null(&disk->error_injection_list,
struct blk_error_inject, entry))) {
list_del_rcu(&inj->entry);
kfree_rcu_mightsleep(inj);
}
- static_branch_dec(&blk_error_injection_enabled);
mutex_unlock(&disk->error_injection_lock);
}