From ee76a126ac1e5c91acb84fc90b83d504d4e38942 Mon Sep 17 00:00:00 2001 From: huanghua <huanghua> Date: Thu, 7 Aug 2008 03:05:34 +0000 Subject: [PATCH] Branch HEAD b=16575 i=tappro i=nikita.danilov correct error handling in cmm_add_mdc() --- lustre/cmm/cmm_device.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lustre/cmm/cmm_device.c b/lustre/cmm/cmm_device.c index 8ecd3e493e..9154dfc919 100644 --- a/lustre/cmm/cmm_device.c +++ b/lustre/cmm/cmm_device.c @@ -190,17 +190,23 @@ static int cmm_add_mdc(const struct lu_env *env, } spin_unlock(&cm->cmm_tgt_guard); ld = ldt->ldt_ops->ldto_device_alloc(env, ldt, cfg); + if (IS_ERR(ld)) + RETURN(PTR_ERR(ld)); + ld->ld_site = cmm2lu_dev(cm)->ld_site; rc = ldt->ldt_ops->ldto_device_init(env, ld, NULL, NULL); if (rc) { ldt->ldt_ops->ldto_device_free(env, ld); - RETURN (rc); + RETURN(rc); } /* pass config to the just created MDC */ rc = ld->ld_ops->ldo_process_config(env, ld, cfg); - if (rc) + if (rc) { + ldt->ldt_ops->ldto_device_fini(env, ld); + ldt->ldt_ops->ldto_device_free(env, ld); RETURN(rc); + } spin_lock(&cm->cmm_tgt_guard); list_for_each_entry_safe(mc, tmp, &cm->cmm_targets, -- GitLab