[RFC for-next 1/3] block: reject unknown status tags in error injection rules
From: Md Haris Iqbal
Date: Wed Aug 26 2026 - 20:03:17 EST
An unknown status tag leaves *status at BLK_STS_OK, which
error_inject_add() then rejects. Fail in match_status() instead, so that
rejecting a bad tag does not rely on BLK_STS_OK being invalid for a rule.
For a single status= this does not change behaviour: an unknown tag still
fails the write with -EINVAL. A repeated status= where an invalid tag
comes first is now rejected instead of being overridden by the later one.
Cc: Christoph Hellwig <hch@xxxxxx>
Signed-off-by: Md Haris Iqbal <haris.iqbal@xxxxxxxxx>
---
block/error-injection.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/block/error-injection.c b/block/error-injection.c
index e14bc4b723ef..47cdd8973adc 100644
--- a/block/error-injection.c
+++ b/block/error-injection.c
@@ -171,15 +171,18 @@ static int match_op(substring_t *args, enum req_op *op)
static int match_status(substring_t *args, blk_status_t *status)
{
const char *tag;
+ int ret = 0;
tag = match_strdup(args);
if (!tag)
return -ENOMEM;
*status = tag_to_blk_status(tag);
- if (!*status)
+ if (!*status) {
pr_warn("invalid status '%s'\n", tag);
+ ret = -EINVAL;
+ }
kfree(tag);
- return 0;
+ return ret;
}
static ssize_t blk_error_injection_parse_options(struct gendisk *disk,
--
2.53.0