All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: snic: fix memory leak with using debugfs_lookup()
@ 2023-02-02 14:10 Greg Kroah-Hartman
  2023-02-08 23:50 ` Martin K. Petersen
  2023-02-14 16:57 ` Martin K. Petersen
  0 siblings, 2 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2023-02-02 14:10 UTC (permalink / raw)
  To: linux-scsi
  Cc: Greg Kroah-Hartman, Karan Tilak Kumar, Sesidhar Baddela,
	James E.J. Bottomley, Martin K. Petersen, linux-kernel

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 <kartilak@cisco.com>
Cc: Sesidhar Baddela <sebaddel@cisco.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/scsi/snic/snic_debugfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/snic/snic_debugfs.c b/drivers/scsi/snic/snic_debugfs.c
index 57bdc3ba49d9..9dd975b36b5b 100644
--- a/drivers/scsi/snic/snic_debugfs.c
+++ b/drivers/scsi/snic/snic_debugfs.c
@@ -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);
 }
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: snic: fix memory leak with using debugfs_lookup()
  2023-02-02 14:10 [PATCH] scsi: snic: fix memory leak with using debugfs_lookup() Greg Kroah-Hartman
@ 2023-02-08 23:50 ` Martin K. Petersen
  2023-02-09 12:27   ` Greg Kroah-Hartman
  2023-02-14 16:57 ` Martin K. Petersen
  1 sibling, 1 reply; 4+ messages in thread
From: Martin K. Petersen @ 2023-02-08 23:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-scsi, Karan Tilak Kumar, Sesidhar Baddela,
	James E.J. Bottomley, Martin K. Petersen, linux-kernel


Greg,

> 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!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: snic: fix memory leak with using debugfs_lookup()
  2023-02-08 23:50 ` Martin K. Petersen
@ 2023-02-09 12:27   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2023-02-09 12:27 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: linux-scsi, Karan Tilak Kumar, Sesidhar Baddela,
	James E.J. Bottomley, linux-kernel

On Wed, Feb 08, 2023 at 06:50:53PM -0500, Martin K. Petersen wrote:
> 
> Greg,
> 
> > 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!

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: snic: fix memory leak with using debugfs_lookup()
  2023-02-02 14:10 [PATCH] scsi: snic: fix memory leak with using debugfs_lookup() Greg Kroah-Hartman
  2023-02-08 23:50 ` Martin K. Petersen
@ 2023-02-14 16:57 ` Martin K. Petersen
  1 sibling, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2023-02-14 16:57 UTC (permalink / raw)
  To: linux-scsi, Greg Kroah-Hartman
  Cc: Martin K . Petersen, Karan Tilak Kumar, Sesidhar Baddela,
	James E.J. Bottomley, linux-kernel

On Thu, 02 Feb 2023 15:10:09 +0100, Greg Kroah-Hartman wrote:

> 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

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-02-14 16:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-02 14:10 [PATCH] scsi: snic: fix memory leak with using debugfs_lookup() Greg Kroah-Hartman
2023-02-08 23:50 ` Martin K. Petersen
2023-02-09 12:27   ` Greg Kroah-Hartman
2023-02-14 16:57 ` Martin K. Petersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.