[PATCH 6.18 038/314] zloop: check for spurious options passed to remove

Sasha Levin
2026-03-10T11:25:15Z

From: Christoph Hellwig <hch@lst.de>

[ Upstream commit 3c4617117a2b7682cf037be5e5533e379707f050 ]

Zloop uses a command option parser for all control commands,
but most options are only valid for adding a new device. Check
for incorrectly specified options in the remove handler.

Fixes: eb0570c7df23 ("block: new zoned loop block device driver")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/block/zloop.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/block/zloop.c b/drivers/block/zloop.c
index 2419677524453..26364e43aeb34 100644
--- a/drivers/block/zloop.c
+++ b/drivers/block/zloop.c
@@ -1076,7 +1076,12 @@ static int zloop_ctl_remove(struct zloop_options *opts)
int ret;

if (!(opts->mask & ZLOOP_OPT_ID)) {
- pr_err("No ID specified\n");
+ pr_err("No ID specified for remove\n");
+ return -EINVAL;
+ }
+
+ if (opts->mask & ~ZLOOP_OPT_ID) {
+ pr_err("Invalid option specified for remove\n");
return -EINVAL;
}

--
2.51.0