From 292548dbc8ba191bc25fbb39b834dd412a085d87 Mon Sep 17 00:00:00 2001 From: nikita Date: Sat, 18 Oct 2008 15:22:51 +0000 Subject: [PATCH] Call cmm_device_free() in the failure path of cmm_device_alloc(). b=16450 --- lustre/ChangeLog | 7 ++++++- lustre/cmm/cmm_device.c | 46 ++++++++++++++++++++++------------------------ 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/lustre/ChangeLog b/lustre/ChangeLog index a7f1479..f3df71e 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -1458,7 +1458,12 @@ Bugzilla : 16450 Description: OSD_COUNTERS-mandatory Details : Make previously optional ->oti_{w,r}_locks sanity checks mandatory to simplify the code. - + +Severity : normal +Bugzilla : 16450 +Description: simplify cmm_device freeing logic. +Details : Call cmm_device_free() in the failure path of cmm_device_alloc(). + -------------------------------------------------------------------------------- 2007-08-10 Cluster File Systems, Inc. diff --git a/lustre/cmm/cmm_device.c b/lustre/cmm/cmm_device.c index aef1da6..3cf494b 100644 --- a/lustre/cmm/cmm_device.c +++ b/lustre/cmm/cmm_device.c @@ -359,6 +359,24 @@ int cmm_upcall(const struct lu_env *env, struct md_device *md, RETURN(rc); } +static struct lu_device *cmm_device_free(const struct lu_env *env, + struct lu_device *d) +{ + struct cmm_device *m = lu2cmm_dev(d); + struct lu_device *next = md2lu_dev(m->cmm_child); + ENTRY; + + LASSERT(m->cmm_tgt_count == 0); + LASSERT(list_empty(&m->cmm_targets)); + if (m->cmm_fld != NULL) { + OBD_FREE_PTR(m->cmm_fld); + m->cmm_fld = NULL; + } + md_device_fini(&m->cmm_md_dev); + OBD_FREE_PTR(m); + RETURN(next); +} + static struct lu_device *cmm_device_alloc(const struct lu_env *env, struct lu_device_type *t, struct lustre_cfg *cfg) @@ -378,32 +396,12 @@ static struct lu_device *cmm_device_alloc(const struct lu_env *env, l->ld_ops = &cmm_lu_ops; OBD_ALLOC_PTR(m->cmm_fld); - if (!m->cmm_fld) - GOTO(out_free_cmm, l = ERR_PTR(-ENOMEM)); + if (!m->cmm_fld) { + cmm_device_free(env, l); + l = ERR_PTR(-ENOMEM); } - - RETURN(l); -out_free_cmm: - OBD_FREE_PTR(m); - return l; -} - -static struct lu_device *cmm_device_free(const struct lu_env *env, - struct lu_device *d) -{ - struct cmm_device *m = lu2cmm_dev(d); - struct lu_device *next = md2lu_dev(m->cmm_child); - ENTRY; - - LASSERT(m->cmm_tgt_count == 0); - LASSERT(list_empty(&m->cmm_targets)); - if (m->cmm_fld != NULL) { - OBD_FREE_PTR(m->cmm_fld); - m->cmm_fld = NULL; } - md_device_fini(&m->cmm_md_dev); - OBD_FREE_PTR(m); - RETURN(next); + RETURN(l); } /* context key constructor/destructor: cmm_key_init, cmm_key_fini */ -- 1.8.3.1