]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/filestore: fix clang static check warn use-after-free 14044/head
authorliuchang0812 <liuchang0812@gmail.com>
Tue, 20 Dec 2016 05:21:40 +0000 (13:21 +0800)
committerNing Yao <yaoning@unitedstack.com>
Mon, 20 Mar 2017 09:38:04 +0000 (09:38 +0000)
Signed-off-by: liuchang0812 <liuchang0812@gmail.com>
(cherry picked from commit 1d359455b3dd6abb383542ba596a03f14ac54dbd)
See: http://tracker.ceph.com/issues/19311

Signed-off-by: yaoning <yaoning@unitedstack.com>
src/os/filestore/FileStore.cc

index d2e969f685fe3193459353679c126f03aae46d67..2e32bd5e111518eaf75275b0ac02cb0ced671e61 100644 (file)
@@ -3103,13 +3103,16 @@ more:
     last = extent++;
   }
   const bool is_last = last->fe_flags & FIEMAP_EXTENT_LAST;
-  free(fiemap);
   if (!is_last) {
     uint64_t xoffset = last->fe_logical + last->fe_length - offset;
     offset = last->fe_logical + last->fe_length;
     len -= xoffset;
+    free(fiemap); /* fix clang warn: use-after-free */
     goto more;
   }
+  else {
+    free(fiemap);
+  }
 
   return r;
 }