HV: hv_balloon: fix memory leak with using debugfs_lookup()
Subsystems (2)
PATCH 1/1 HV: hv_balloon: 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.
--- drivers/hv/hv_balloon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hv/hv_balloon.c +1 -1
@@ -1963,7 +1963,7 @@ static void hv_balloon_debugfs_init(struct hv_dynmem_device *b)static void hv_balloon_debugfs_exit (struct hv_dynmem_device *b) { -debugfs_remove (debugfs_lookup ("hv-balloon" ,NULL )); +debugfs_lookup_and_remove ("hv-balloon" ,NULL ); }#else
Signature · 1 line
2.39.1
From: Greg Kroah-Hartman <[email protected]> Sent: Thursday, February 2, 2023 6:09 AM
Quoted 6 lines
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 7 lines
Cc "K. Y. Srinivasan" <[email protected]>Cc Haiyang Zhang <[email protected]>Cc Wei Liu <[email protected]>Cc Dexuan Cui <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Add a Fixes: tag? This hv_balloon debugfs code was added in v6.0, And I see that debugfs_lookup_and_remove() was also added in v6.0.
Quoted 9 lines
--- drivers/hv/hv_balloon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/hv/hv_balloon.c +0
-0
drivers/hv/hv_balloon.c static void hv_balloon_debugfs_init(struct hv_dynmem_device *b) · line 1969
Quoted 8 lines
drivers/hv/hv_balloon.c +1
-1@@ -1963,7 +1963,7 @@ static void hv_balloon_debugfs_init(struct hv_dynmem_device *b)static void hv_balloon_debugfs_exit (struct hv_dynmem_device *b) { -debugfs_remove (debugfs_lookup ("hv-balloon" ,NULL )); +debugfs_lookup_and_remove ("hv-balloon" ,NULL ); }#else
Quoted 16 lines · Michael Kelley (LINUX)
From: Greg Kroah-Hartman <[email protected]> Sent: Thursday, February 2, 2023 6:09 AM
Quoted 6 lines
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 7 lines
Cc "K. Y. Srinivasan" <[email protected]>Cc Haiyang Zhang <[email protected]>Cc Wei Liu <[email protected]>Cc Dexuan Cui <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 4 lines
Add a Fixes: tag? This
hv_balloondebugfs code was added in v6.0, And I see thatdebugfs_lookup_and_remove()was also added in v6.0.Fixes d180e0a1be6c ("Drivers: hv: Create debugfs file with hyper-v balloon usage information")
Will do, thanks.
greg k-h