mm/slub: fix memory leak with using debugfs_lookup()
Subsystems (2)
PATCH 1/1 mm/slub: fix memory leak with using debugfs_lookup()
When calling debugfs_lookup() the result must have dput() called on it, otherwise the memory will leak over time. To make things simpler, just call debugfs_lookup_and_remove() instead which handles all of the logic at once.
--- mm/slub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/slub.c +1 -1
@@ -6449,7 +6449,7 @@ static void debugfs_slab_add(struct kmem_cache *s)void debugfs_slab_release (struct kmem_cache *s) { -debugfs_remove_recursive (debugfs_lookup (s->name, slab_debugfs_root)); +debugfs_lookup_and_remove (s->name, slab_debugfs_root); }static int __init slab_debugfs_init (void )
Signature · 1 line
2.39.1
Quoted 25 lines · Greg Kroah-Hartman
When calling
debugfs_lookup()the result must havedput()called on it, otherwise the memory will leak over time. To make things simpler, just calldebugfs_lookup_and_remove()instead which handles all of the logic at once.Cc Christoph Lameter <[email protected]>Cc Pekka Enberg <[email protected]>Cc David Rientjes <[email protected]>Cc Joonsoo Kim <[email protected]>Cc Andrew Morton <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Roman Gushchin <[email protected]>Cc Hyeonggon Yoo <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- mm/slub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/slub.c +0
-0
mm/slub.c static void debugfs_slab_add(struct kmem_cache *s) · line 6453
Quoted 6 lines
mm/slub.c +1
-1@@ -6449,7 +6449,7 @@ static void debugfs_slab_add(struct kmem_cache *s)void debugfs_slab_release (struct kmem_cache *s) { -debugfs_remove_recursive (debugfs_lookup (s->name, slab_debugfs_root)); +debugfs_lookup_and_remove (s->name, slab_debugfs_root); }
Looks good to me.
Thank you for fixing this.
Quoted 4 lines
mm/slub.c +0
-0static int __init slab_debugfs_init (void )Signature · 1 line
2.39.1
Quoted 5 lines · Greg Kroah-Hartman
When calling
debugfs_lookup()the result must havedput()called on it, otherwise the memory will leak over time. To make things simpler, just calldebugfs_lookup_and_remove()instead which handles all of the logic at once.
Quoted 11 lines
Cc Christoph Lameter <[email protected]>Cc Pekka Enberg <[email protected]>Cc David Rientjes <[email protected]>Cc Joonsoo Kim <[email protected]>Cc Andrew Morton <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Roman Gushchin <[email protected]>Cc Hyeonggon Yoo <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Good catch!
Thanks!
Quoted 5 lines · Greg Kroah-Hartman
When calling
debugfs_lookup()the result must havedput()called on it, otherwise the memory will leak over time. To make things simpler, just calldebugfs_lookup_and_remove()instead which handles all of the logic at once.
Quoted 11 lines
Cc Christoph Lameter <[email protected]>Cc Pekka Enberg <[email protected]>Cc David Rientjes <[email protected]>Cc Joonsoo Kim <[email protected]>Cc Andrew Morton <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Roman Gushchin <[email protected]>Cc Hyeonggon Yoo <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 5 lines · Greg Kroah-Hartman
When calling
debugfs_lookup()the result must havedput()called on it, otherwise the memory will leak over time. To make things simpler, just calldebugfs_lookup_and_remove()instead which handles all of the logic at once.
Quoted 11 lines
Cc Christoph Lameter <[email protected]>Cc Pekka Enberg <[email protected]>Cc David Rientjes <[email protected]>Cc Joonsoo Kim <[email protected]>Cc Andrew Morton <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Roman Gushchin <[email protected]>Cc Hyeonggon Yoo <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Thanks, added to slab/for-6.3/fixes
Quoted 17 lines
--- mm/slub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/slub.c +1
-1@@ -6449,7 +6449,7 @@ static void debugfs_slab_add(struct kmem_cache *s)void debugfs_slab_release (struct kmem_cache *s) { -debugfs_remove_recursive (debugfs_lookup (s->name, slab_debugfs_root)); +debugfs_lookup_and_remove (s->name, slab_debugfs_root); }static int __init slab_debugfs_init (void )