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

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