Whamcloud - gitweb
LU-10656 ldlm: fix export reference 39/31139/5
authorHongchao Zhang <hongchao.zhang@intel.com>
Sun, 28 Jan 2018 19:25:42 +0000 (03:25 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 6 Mar 2018 19:14:11 +0000 (19:14 +0000)
In ptlrpc_connect_interpert, the export reference could be
leaked if there is error before the following class_exp_put.

Change-Id: I9ddd82fa1bbf8e17079e9746202be63e6233c052
Signed-off-by: Hongchao Zhang <hongchao.zhang@intel.com>
Reviewed-on: https://review.whamcloud.com/31139
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Li Dongyang <dongyangli@ddn.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/ptlrpc/import.c

index 126b7e7..dcd42f0 100644 (file)
@@ -975,7 +975,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
         __u64 old_connect_flags;
         int msg_flags;
        struct obd_connect_data *ocd;
-       struct obd_export *exp;
+       struct obd_export *exp = NULL;
        int ret;
        ENTRY;
 
@@ -1100,6 +1100,8 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
        rc = ptlrpc_connect_set_flags(imp, ocd, old_connect_flags, exp,
                                      aa->pcaa_initial_connect);
        class_export_put(exp);
+       exp = NULL;
+
        if (rc != 0)
                GOTO(out, rc);
 
@@ -1271,6 +1273,9 @@ out:
        imp->imp_connect_tried = 1;
        spin_unlock(&imp->imp_lock);
 
+       if (exp != NULL)
+               class_export_put(exp);
+
         if (rc != 0) {
                 IMPORT_SET_STATE(imp, LUSTRE_IMP_DISCON);
                 if (rc == -EACCES) {