From: Kefu Chai Date: Wed, 23 Nov 2016 06:48:11 +0000 (+0800) Subject: FileStore::_do_fiemap: do not reference fiemap after it is freed X-Git-Tag: v0.94.10~9^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=7106f426c96978a0a41e9d1482239a4da505157e;p=ceph.git FileStore::_do_fiemap: do not reference fiemap after it is freed `last` points to fiemap::fm_extends[n], and if fiemap gets freed, we can not reference any of its fieldis. so we could remember the check result before freeing it. Signed-off-by: Kefu Chai (cherry picked from commit c3748fa7737b6c43de2dae5d957fcff01322515c) Conflicts: src/os/FileStore.cc put the parameter is_last in the right place --- diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 53663241ec545..61bad358ff162 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -2957,9 +2957,10 @@ more: i++; extent++; } + const bool is_last = last->fe_flags & FIEMAP_EXTENT_LAST; free(fiemap); - if (!(last->fe_flags & FIEMAP_EXTENT_LAST)) { + if (!is_last) { uint64_t xoffset = last->fe_logical + last->fe_length - offset; offset = last->fe_logical + last->fe_length; len -= xoffset;