Blame SOURCES/0094-multipath-return-failure-on-an-invalid-remove-comman.patch

aab12e
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
aab12e
From: Benjamin Marzinski <bmarzins@redhat.com>
aab12e
Date: Wed, 30 Mar 2022 15:14:56 -0500
aab12e
Subject: [PATCH] multipath: return failure on an invalid remove command
aab12e
aab12e
When "multipath -f" is run on a device that doesn't exist or isn't a
aab12e
multipath device, the command will not remove any device, but it will
aab12e
still return success.  Multiple functions rely on _dm_flush_map()
aab12e
returning success when called with name that doesn't match any
aab12e
multipath device. So before calling _dm_flush_map(), call dm_is_mpath(),
aab12e
to check if the device exists and is a multipath device, and return
aab12e
failure if it's not.
aab12e
aab12e
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
aab12e
Reviewed-by: Martin Wilck 
aab12e
---
aab12e
 multipath/main.c | 5 +++++
aab12e
 1 file changed, 5 insertions(+)
aab12e
aab12e
diff --git a/multipath/main.c b/multipath/main.c
aab12e
index 14d045c9..d5e6499c 100644
aab12e
--- a/multipath/main.c
aab12e
+++ b/multipath/main.c
aab12e
@@ -1150,6 +1150,11 @@ main (int argc, char *argv[])
aab12e
 	if (retries < 0)
aab12e
 		retries = conf->remove_retries;
aab12e
 	if (cmd == CMD_FLUSH_ONE) {
aab12e
+		if (dm_is_mpath(dev) != 1) {
aab12e
+			condlog(0, "%s is not a multipath device", dev);
aab12e
+			r = RTVL_FAIL;
aab12e
+			goto out;
aab12e
+		}
aab12e
 		r = dm_suspend_and_flush_map(dev, retries) ?
aab12e
 		    RTVL_FAIL : RTVL_OK;
aab12e
 		goto out;