[dm-devel] [PATCH v3 86/87] libmultipath: adopt_paths(): set pp->mpp only on success
mwilck at suse.com
mwilck at suse.com
Wed Aug 19 13:18:18 UTC 2020
From: Martin Wilck <mwilck at suse.com>
Make sure that pp->mpp is only set for paths that have been
successfully added to mpp->paths.
Suggested-by: Benjamin Marzinki <bmarzins at redhat.com>
Signed-off-by: Martin Wilck <mwilck at suse.com>
---
libmultipath/structs_vec.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c
index 2d85df9..cc2dafa 100644
--- a/libmultipath/structs_vec.c
+++ b/libmultipath/structs_vec.c
@@ -248,14 +248,10 @@ int adopt_paths(vector pathvec, struct multipath *mpp)
pp->dev, mpp->alias);
continue;
}
- pp->mpp = mpp;
if (pp->initialized == INIT_REMOVED)
continue;
- condlog(3, "%s: ownership set to %s",
- pp->dev, mpp->alias);
-
if (!mpp->paths && !(mpp->paths = vector_alloc()))
- return 1;
+ goto err;
conf = get_multipath_config();
pthread_cleanup_push(put_multipath_config, conf);
@@ -270,10 +266,17 @@ int adopt_paths(vector pathvec, struct multipath *mpp)
if (!find_path_by_devt(mpp->paths, pp->dev_t) &&
store_path(mpp->paths, pp))
- return 1;
+ goto err;
+
+ pp->mpp = mpp;
+ condlog(3, "%s: ownership set to %s",
+ pp->dev, mpp->alias);
}
}
return 0;
+err:
+ condlog(1, "error setting ownership of %s to %s", pp->dev, mpp->alias);
+ return 1;
}
void orphan_path(struct path *pp, const char *reason)
--
2.28.0
More information about the dm-devel
mailing list