From: mwilck@suse.com Subject: [PATCH v3 86/87] libmultipath: adopt_paths(): set pp->mpp only on success Date: Wed, 19 Aug 2020 15:18:18 +0200 Message-ID: <20200819131819.13493-4-mwilck@suse.com> References: <20200819131819.13493-1-mwilck@suse.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20200819131819.13493-1-mwilck@suse.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com To: Christophe Varoqui , Benjamin Marzinski Cc: dm-devel@redhat.com, Martin Wilck List-Id: dm-devel.ids From: Martin Wilck Make sure that pp->mpp is only set for paths that have been successfully added to mpp->paths. Suggested-by: Benjamin Marzinki Signed-off-by: Martin Wilck --- 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