Whamcloud - gitweb
LU-7078 llite: reset md->lmv to NULL 82/16382/3
authorwang di <di.wang@intel.com>
Thu, 10 Sep 2015 04:06:11 +0000 (21:06 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 19 Sep 2015 03:45:22 +0000 (03:45 +0000)
ll_update_lsm_md() should reset md->lmv to NULL
right after it is assigned to lli_lsm_md, otherwise
it might be double freed if failure happens.

Signed-off-by: wang di <di.wang@intel.com>
Change-Id: I4f069e3445a957860c2853c6f32104885edc33fa
Reviewed-on: http://review.whamcloud.com/16382
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/llite/llite_lib.c

index 4a21af3..afb7b55 100644 (file)
@@ -1329,6 +1329,9 @@ static int ll_update_lsm_md(struct inode *inode, struct lustre_md *md)
                if (rc != 0)
                        RETURN(rc);
 
+               /* set md->lmv to NULL, so the following free lustre_md
+                * will not free this lsm */
+               md->lmv = NULL;
                lli->lli_lsm_md = lsm;
 
                OBD_ALLOC_PTR(attr);
@@ -1356,10 +1359,6 @@ static int ll_update_lsm_md(struct inode *inode, struct lustre_md *md)
 
                OBD_FREE_PTR(attr);
 
-
-                       /* set lsm_md to NULL, so the following free lustre_md
-                * will not free this lsm */
-               md->lmv = NULL;
                CDEBUG(D_INODE, "Set lsm %p magic %x to "DFID"\n", lsm,
                       lsm->lsm_md_magic, PFID(ll_inode2fid(inode)));
                RETURN(0);