Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

misc: vmw_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.

Cc: Nadav Amit <namit@vmware.com>
Cc: VMware PV-Drivers Reviewers <pv-drivers@vmware.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20230202141100.2291188-1-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+1 -1
+1 -1
drivers/misc/vmw_balloon.c
··· 1709 1709 static void __exit vmballoon_debugfs_exit(struct vmballoon *b) 1710 1710 { 1711 1711 static_key_disable(&balloon_stat_enabled.key); 1712 - debugfs_remove(debugfs_lookup("vmmemctl", NULL)); 1712 + debugfs_lookup_and_remove("vmmemctl", NULL); 1713 1713 kfree(b->stats); 1714 1714 b->stats = NULL; 1715 1715 }