[PATCH 1/4] xfsprogs: Free all data in libxfs_umount; call from xfs_copy as well

Eric Sandeen
2015-08-20T18:08:32Z

libxfs_umount was failing to free a handful of resources; fix that up.
Call it from xfs_copy as well, while we're at it; every other libxfs_mount
has a libxfs_umount counterpart, at least on a clean exit.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
copy/xfs_copy.c | 2 ++
libxfs/init.c | 9 +++++++++
2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/copy/xfs_copy.c b/copy/xfs_copy.c
index e13f468..4497b7f 100644
--- a/copy/xfs_copy.c
+++ b/copy/xfs_copy.c
@@ -1165,6 +1165,8 @@ main(int argc, char **argv)
}

check_errors();
+ libxfs_umount(mp);
+
return 0;
}

diff --git a/libxfs/init.c b/libxfs/init.c
index 2859f94..c7f9dc8 100644
--- a/libxfs/init.c
+++ b/libxfs/init.c
@@ -832,6 +832,15 @@ libxfs_umount(xfs_mount_t *mp)
pag = radix_tree_delete(&mp->m_perag_tree, agno);
kmem_free(pag);
}
+
+ kmem_free(mp->m_attr_geo);
+ kmem_free(mp->m_dir_geo);
+
+ kmem_free(mp->m_rtdev_targp);
+ if (mp->m_logdev_targp != mp->m_ddev_targp)
+ kmem_free(mp->m_logdev_targp);
+ kmem_free(mp->m_ddev_targp);