Bug 48651 - [TRIVIAl]'xfs_uuid_table' allocated in xfs_uuid_mount() is never freed
Summary: [TRIVIAl]'xfs_uuid_table' allocated in xfs_uuid_mount() is never freed
Status: RESOLVED CODE_FIX
Alias: None
Product: File System
Classification: Unclassified
Component: XFS (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: XFS Guru
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-09 12:41 UTC by Eugene A. Shatokhin
Modified: 2016-09-22 16:14 UTC (History)
5 users (show)

See Also:
Kernel Version: 3.6
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Eugene A. Shatokhin 2012-10-09 12:41:13 UTC
The memory for 'xfs_uuid_table' is allocated in xfs_uuid_mount() but is never freed (see xfs_mount.c).

Not sure where exactly it is appropriate to call kmem_free() for it. Perhaps, - in the exit-function of XFS kernel module or when the table becomes empty?

Found this problem with the memory leak detector from KEDR Framework when running xfstests suite.
Comment 1 xerofoify 2014-04-18 19:25:20 UTC
Firstly ,I do not know the codebase of XFS that well, however it will depend on when the table is freed if when the volumes are unmounted in that case I would free after the table is empty , but I would recommend doing in the module_exit() function for xfs due to the certainity it will sucess in not causing further issues as you then have certainty the filesystem module is no longer in use.
Comment 2 Eric Sandeen 2014-05-20 04:01:20 UTC
Freeing it when the module is unloaded should be sufficient.

In normal use, unmounting a filesystem creates a hole in the table, which the next mount can fill.

If you mount a lot of unique UUID filesystems without unmounting any in between, the table will grow accordingly, and unmounting won't shrink it - i.e. the table only grows as the number of concurrently mounted filesystem grows, but that doesn't seem like a particularly critical problem to fix.
Comment 3 xerofoify 2014-06-15 02:37:11 UTC
Can you tell me where the module_exit is so I can use kmee_free to free it.
Please tell me the file and the values send to xfs_uuid_table in order to correctly free it.
Cheers Nick
Comment 4 Eric Sandeen 2016-09-22 16:14:42 UTC
Fixed in v4.4:

commit af3b63822e73b66f3ca9927b46df8b873ab8c6ec
Author: Darrick J. Wong <darrick.wong@oracle.com>
Date:   Tue Nov 3 13:06:34 2015 +1100

    xfs: don't leak uuid table on rmmod
    
    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>

Note You need to log in before you can comment on or make changes to this bug.