Skip to contentSkip to conversation

scsi: snic: fix memory leak with using debugfs_lookup()

PATCH Applied Greg Kroah-Hartman 2 participants 4 messages Feb 2, 2023 – Feb 14, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: snic: 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 Karan Tilak Kumar <[email protected]>
Cc Sesidhar Baddela <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
Cc "Martin K. Petersen" <[email protected]>
---
 drivers/scsi/snic/snic_debugfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/snic/snic_debugfs.c +2 -2
index 57bdc3ba49d9..9dd975b36b5b 100644
@@ -437,6 +437,6 @@ void snic_trc_debugfs_init(void)
 void
 snic_trc_debugfs_term(void)
 {
-	debugfs_remove(debugfs_lookup(TRC_FILE, snic_glob->trc_root));
-	debugfs_remove(debugfs_lookup(TRC_ENABLE_FILE, snic_glob->trc_root));
+	debugfs_lookup_and_remove(TRC_FILE, snic_glob->trc_root);
+	debugfs_lookup_and_remove(TRC_ENABLE_FILE, snic_glob->trc_root);
 }
Signature · 1 line
2.39.1
#1 lore raw

Greg,

Quoted 4 lines

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.

Applied to 6.3/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#2 lore raw
Quoted 9 lines · Martin K. Petersen

Greg,

Quoted 4 lines

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.

Applied to 6.3/scsi-staging, thanks!

Wonderful, thank you!

#3 lore raw
In reply to Greg Kroah-Hartman
Quoted 6 lines · Greg Kroah-Hartman

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.

Applied to 6.3/scsi-queue, thanks!

[1/1] scsi: snic: fix memory leak with using debugfs_lookup()

      https://git.kernel.org/mkp/scsi/c/ad0e4e2fab92
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering