diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c
index f32b71468d79e9b4755f218b7fbe433866c0afec..99eba5a2fb30f1f89e455ae18d3a01e20b0100a4 100644
--- a/lustre/mdc/mdc_request.c
+++ b/lustre/mdc/mdc_request.c
@@ -118,7 +118,7 @@ int mdc_getstatus(struct obd_export *exp, struct ll_fid *rootfid)
 }
 
 static
-int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size, 
+int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size,
                        unsigned int acl_size, struct ptlrpc_request *req)
 {
         struct obd_device *obddev = class_exp2obd(exp);
@@ -169,12 +169,12 @@ int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size,
         }
 
         if (body->valid & OBD_MD_FLMODEASIZE) {
-                if (exp->exp_obd->u.cli.cl_max_mds_easize < body->max_mdsize) 
-                        exp->exp_obd->u.cli.cl_max_mds_easize = 
+                if (exp->exp_obd->u.cli.cl_max_mds_easize < body->max_mdsize)
+                        exp->exp_obd->u.cli.cl_max_mds_easize =
                                                 body->max_mdsize;
-                if (exp->exp_obd->u.cli.cl_max_mds_cookiesize < 
+                if (exp->exp_obd->u.cli.cl_max_mds_cookiesize <
                                                 body->max_cookiesize)
-                        exp->exp_obd->u.cli.cl_max_mds_cookiesize = 
+                        exp->exp_obd->u.cli.cl_max_mds_cookiesize =
                                                 body->max_cookiesize;
         }
 
@@ -232,7 +232,7 @@ int mdc_getattr_name(struct obd_export *exp, struct ll_fid *fid,
 
         mdc_pack_req_body(req, REQ_REC_OFF, valid, fid, ea_size,
                           MDS_BFLAG_EXT_FLAGS/*request "new" flags(bug 9486)*/);
- 
+
         LASSERT(strnlen(filename, namelen) == namelen - 1);
         memcpy(lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 1, namelen),
                filename, namelen);
@@ -606,6 +606,12 @@ void mdc_set_open_replay_data(struct obd_client_handle *och,
                 }
 
                 spin_lock(&open_req->rq_lock);
+                if (!open_req->rq_replay) {
+                        OBD_FREE(mod, sizeof(*mod));
+                        spin_unlock(&open_req->rq_lock);
+                        return;
+                }
+
                 och->och_mod = mod;
                 mod->mod_och = och;
                 mod->mod_open_req = open_req;
@@ -1004,7 +1010,7 @@ static int mdc_statfs(struct obd_device *obd, struct obd_statfs *osfs,
         int rc;
         ENTRY;
 
-        /*Since the request might also come from lprocfs, so we need 
+        /*Since the request might also come from lprocfs, so we need
          *sync this with client_disconnect_export Bug15684*/
         down_read(&obd->u.cli.cl_sem);
         if (obd->u.cli.cl_import)
@@ -1012,7 +1018,6 @@ static int mdc_statfs(struct obd_device *obd, struct obd_statfs *osfs,
         up_read(&obd->u.cli.cl_sem);
         if (!imp)
                 RETURN(-ENODEV);
-        
 
         /* We could possibly pass max_age in the request (as an absolute
          * timestamp or a "seconds.usec ago") so the target can avoid doing
@@ -1020,7 +1025,7 @@ static int mdc_statfs(struct obd_device *obd, struct obd_statfs *osfs,
          * during mount that would help a bit).  Having relative timestamps
          * is not so great if request processing is slow, while absolute
          * timestamps are not ideal because they need time synchronization. */
-        req = ptlrpc_prep_req(imp, LUSTRE_MDS_VERSION, MDS_STATFS, 1, NULL, 
+        req = ptlrpc_prep_req(imp, LUSTRE_MDS_VERSION, MDS_STATFS, 1, NULL,
                               NULL);
         if (!req)
                 GOTO(output, rc = -ENOMEM);
@@ -1109,7 +1114,7 @@ static int mdc_unpin(struct obd_export *exp,
         struct ptlrpc_request *req;
         struct mds_body *body;
         __u32 size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
-        int rc; 
+        int rc;
         ENTRY;
 
         if (handle->och_magic != OBD_CLIENT_HANDLE_MAGIC)
@@ -1274,7 +1279,7 @@ int mdc_init_ea_size(struct obd_export *mdc_exp, struct obd_export *lov_exp)
         stripes = min(desc.ld_tgt_count, (__u32)LOV_MAX_STRIPE_COUNT);
         lsm.lsm_stripe_count = stripes;
         size = obd_size_diskmd(lov_exp, &lsm);
-        
+
         if (cli->cl_max_mds_easize < size)
                 cli->cl_max_mds_easize = size;
 
@@ -1290,7 +1295,7 @@ int mdc_init_ea_size(struct obd_export *mdc_exp, struct obd_export *lov_exp)
 
         CDEBUG(D_HA, "updating max_mdsize/max_cookiesize: %d/%d\n",
                cli->cl_max_mds_easize, cli->cl_max_mds_cookiesize);
-        
+
         RETURN(0);
 }
 
@@ -1300,7 +1305,7 @@ static int mdc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
         ENTRY;
 
         switch (stage) {
-        case OBD_CLEANUP_EARLY: 
+        case OBD_CLEANUP_EARLY:
         case OBD_CLEANUP_EXPORTS:
                 /* If we set up but never connected, the
                    client import will not have been cleaned. */
@@ -1342,7 +1347,7 @@ static int mdc_cleanup(struct obd_device *obd)
 
 
 static int mdc_llog_init(struct obd_device *obd, struct obd_device *tgt,
-                         int count, struct llog_catid *logid, 
+                         int count, struct llog_catid *logid,
                          struct obd_uuid *uuid)
 {
         struct llog_ctxt *ctxt;
@@ -1388,7 +1393,7 @@ static int mdc_process_config(struct obd_device *obd, obd_count len, void *buf)
         int rc = 0;
 
         lprocfs_mdc_init_vars(&lvars);
-        
+
         rc = class_process_proc_param(PARAM_MDC, lvars.obd_vars, lcfg, obd);
         return(rc);
 }