From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: linux-usb@vger.kernel.org
Cc: "Yehezkel Bernat" <YehezkelShB@gmail.com>,
"Michael Jamet" <michael.jamet@intel.com>,
"Lukas Wunner" <lukas@wunner.de>,
"Andreas Noever" <andreas.noever@gmail.com>,
"Christian Schaubschläger" <christian.schaubschlaeger@gmx.at>,
"Gil Fine" <gil.fine@linux.intel.com>,
"Mika Westerberg" <mika.westerberg@linux.intel.com>
Subject: [PATCH 1/5] thunderbolt: Fix memory leak in margining
Date: Mon, 6 Mar 2023 13:36:01 +0200 [thread overview]
Message-ID: <20230306113605.46137-2-mika.westerberg@linux.intel.com> (raw)
In-Reply-To: <20230306113605.46137-1-mika.westerberg@linux.intel.com>
Memory for the usb4->margining needs to be relased for the upstream port
of the router as well, even though the debugfs directory gets released
with the router device removal. Fix this.
Fixes: d0f1e0c2a699 ("thunderbolt: Add support for receiver lane margining")
Cc: stable@vger.kernel.org
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
drivers/thunderbolt/debugfs.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/thunderbolt/debugfs.c b/drivers/thunderbolt/debugfs.c
index 4339e706cc3a..f92ad71ef983 100644
--- a/drivers/thunderbolt/debugfs.c
+++ b/drivers/thunderbolt/debugfs.c
@@ -942,7 +942,8 @@ 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);
- debugfs_remove_recursive(debugfs_lookup("margining", parent));
+ if (parent)
+ debugfs_remove_recursive(debugfs_lookup("margining", parent));
kfree(port->usb4->margining);
port->usb4->margining = NULL;
@@ -967,19 +968,18 @@ static void margining_switch_init(struct tb_switch *sw)
static void margining_switch_remove(struct tb_switch *sw)
{
+ struct tb_port *upstream, *downstream;
struct tb_switch *parent_sw;
- struct tb_port *downstream;
u64 route = tb_route(sw);
if (!route)
return;
- /*
- * Upstream is removed with the router itself but we need to
- * remove the downstream port margining directory.
- */
+ upstream = tb_upstream_port(sw);
parent_sw = tb_switch_parent(sw);
downstream = tb_port_at(route, parent_sw);
+
+ margining_port_remove(upstream);
margining_port_remove(downstream);
}
--
2.39.1
next prev parent reply other threads:[~2023-03-06 11:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-06 11:36 [PATCH 0/5] thunderbolt: A couple of fixes Mika Westerberg
2023-03-06 11:36 ` Mika Westerberg [this message]
2023-03-06 11:36 ` [PATCH 2/5] thunderbolt: Add missing UNSET_INBOUND_SBTX for retimer access Mika Westerberg
2023-03-06 11:36 ` [PATCH 3/5] thunderbolt: Call tb_check_quirks() after initializing adapters Mika Westerberg
2023-03-06 11:36 ` [PATCH 4/5] thunderbolt: Limit USB3 bandwidth of certain Intel USB4 host routers Mika Westerberg
2023-03-06 11:36 ` [PATCH 5/5] thunderbolt: Use scale field when allocating USB3 bandwidth Mika Westerberg
2023-03-06 15:12 ` Yehezkel Bernat
2023-03-13 10:07 ` [PATCH 0/5] thunderbolt: A couple of fixes Mika Westerberg
2023-03-13 13:07 ` Christian Schaubschläger
2023-03-14 7:32 ` Mika Westerberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230306113605.46137-2-mika.westerberg@linux.intel.com \
--to=mika.westerberg@linux.intel.com \
--cc=YehezkelShB@gmail.com \
--cc=andreas.noever@gmail.com \
--cc=christian.schaubschlaeger@gmx.at \
--cc=gil.fine@linux.intel.com \
--cc=linux-usb@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=michael.jamet@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).