dm-unstripe accepts a stripe index that is equal to the number of
configured stripes.  Valid indexes are zero based, so that value is one
past the last stripe.

The out-of-range value can later be used in mapping calculations and
describe a stripe that does not exist.

Reject stripe indexes greater than or equal to the configured stripe
count.

Assisted-by: Codex:gpt-5.5-cyber-preview
Signed-off-by: Samuel Moelius <[email protected]>
---
 drivers/md/dm-unstripe.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm-unstripe.c b/drivers/md/dm-unstripe.c
index bfcbe6bfa71a..b1a8ec69ccad 100644
--- a/drivers/md/dm-unstripe.c
+++ b/drivers/md/dm-unstripe.c
@@ -69,8 +69,8 @@ static int unstripe_ctr(struct dm_target *ti, unsigned int 
argc, char **argv)
                goto err;
        }
 
-       if (uc->unstripe > uc->stripes && uc->stripes > 1) {
-               ti->error = "Please provide stripe between [0, # of stripes]";
+       if (uc->unstripe >= uc->stripes) {
+               ti->error = "Invalid stripe number";
                goto err;
        }
 
-- 
2.43.0


Reply via email to