xfs: don't leak uuid table on rmmod
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 3 Nov 2015 02:06:34 +0000 (13:06 +1100)
committerDave Chinner <david@fromorbit.com>
Tue, 3 Nov 2015 02:06:34 +0000 (13:06 +1100)
Don't leak the UUID table when the module is unloaded.
(Found with kmemleak.)

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/xfs/xfs_mount.c
fs/xfs/xfs_mount.h
fs/xfs/xfs_super.c

index bf92e0c037c7378cadf1848a4324968170e1ae29..fe6fe8a889d5013169c927ccd1d017c4c4712138 100644 (file)
@@ -47,6 +47,16 @@ static DEFINE_MUTEX(xfs_uuid_table_mutex);
 static int xfs_uuid_table_size;
 static uuid_t *xfs_uuid_table;
 
+void
+xfs_uuid_table_free(void)
+{
+       if (xfs_uuid_table_size == 0)
+               return;
+       kmem_free(xfs_uuid_table);
+       xfs_uuid_table = NULL;
+       xfs_uuid_table_size = 0;
+}
+
 /*
  * See if the UUID is unique among mounted XFS filesystems.
  * Mount fails if UUID is nil or a FS with the same UUID is already mounted.
index 7999e91cd49ad862d5fbeb29a5e5487ed94509a8..d6cbdcb168dde06d463c741aefce0298b2e94568 100644 (file)
@@ -312,6 +312,7 @@ typedef struct xfs_perag {
        int             pagb_count;     /* pagb slots in use */
 } xfs_perag_t;
 
+extern void    xfs_uuid_table_free(void);
 extern int     xfs_log_sbcount(xfs_mount_t *);
 extern __uint64_t xfs_default_resblks(xfs_mount_t *mp);
 extern int     xfs_mountfs(xfs_mount_t *mp);
index 904f637cfa5f3c2f40c0e7c4bb0ba6ffe3b65d1a..29531ec19ba6c2809532939a9ce2ac7392a12235 100644 (file)
@@ -1896,6 +1896,7 @@ exit_xfs_fs(void)
        xfs_mru_cache_uninit();
        xfs_destroy_workqueues();
        xfs_destroy_zones();
+       xfs_uuid_table_free();
 }
 
 module_init(init_xfs_fs);