* [PATCH] thunderbolt:debugfs:Fix memory leak with using debugfs_lookup()
@ 2023-11-22 8:02 Yaxiong Tian
2023-11-27 10:59 ` Mika Westerberg
0 siblings, 1 reply; 2+ messages in thread
From: Yaxiong Tian @ 2023-11-22 8:02 UTC (permalink / raw)
To: michael.jamet, gregkh, andreas.noever, mika.westerberg,
YehezkelShB
Cc: tianyaxiong, linux-usb, linux-kernel
From: Yaxiong Tian <tianyaxiong@kylinos.cn>
As Greg said,When calling debugfs_lookup() the result must have dput()
called on it,otherwise the memory will leak over time.
So just call debugfs_lookup_and_remove() instead.
Fixes: d0f1e0c2a699 ("thunderbolt: Add support for receiver lane margining")
Signed-off-by: Yaxiong Tian <tianyaxiong@kylinos.cn>
---
drivers/thunderbolt/debugfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/thunderbolt/debugfs.c b/drivers/thunderbolt/debugfs.c
index c9ddd49138d8..e324cd899719 100644
--- a/drivers/thunderbolt/debugfs.c
+++ b/drivers/thunderbolt/debugfs.c
@@ -959,7 +959,7 @@ static void margining_port_remove(struct tb_port *port)
snprintf(dir_name, sizeof(dir_name), "port%d", port->port);
parent = debugfs_lookup(dir_name, port->sw->debugfs_dir);
if (parent)
- debugfs_remove_recursive(debugfs_lookup("margining", parent));
+ debugfs_lookup_and_remove("margining", parent);
kfree(port->usb4->margining);
port->usb4->margining = NULL;
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] thunderbolt:debugfs:Fix memory leak with using debugfs_lookup()
2023-11-22 8:02 [PATCH] thunderbolt:debugfs:Fix memory leak with using debugfs_lookup() Yaxiong Tian
@ 2023-11-27 10:59 ` Mika Westerberg
0 siblings, 0 replies; 2+ messages in thread
From: Mika Westerberg @ 2023-11-27 10:59 UTC (permalink / raw)
To: Yaxiong Tian
Cc: michael.jamet, gregkh, andreas.noever, YehezkelShB, tianyaxiong,
linux-usb, linux-kernel
On Wed, Nov 22, 2023 at 04:02:43PM +0800, Yaxiong Tian wrote:
> From: Yaxiong Tian <tianyaxiong@kylinos.cn>
>
> As Greg said,When calling debugfs_lookup() the result must have dput()
> called on it,otherwise the memory will leak over time.
> So just call debugfs_lookup_and_remove() instead.
>
> Fixes: d0f1e0c2a699 ("thunderbolt: Add support for receiver lane margining")
> Signed-off-by: Yaxiong Tian <tianyaxiong@kylinos.cn>
Slightly modified the commit log and applied to thunderbolt.git/fixes, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-11-27 10:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-22 8:02 [PATCH] thunderbolt:debugfs:Fix memory leak with using debugfs_lookup() Yaxiong Tian
2023-11-27 10:59 ` Mika Westerberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox