]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
thunderbolt: Set tb->root_switch to NULL when domain is stopped
authorMika Westerberg <mika.westerberg@linux.intel.com>
Wed, 19 Nov 2025 10:49:30 +0000 (12:49 +0200)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Tue, 5 May 2026 11:53:46 +0000 (13:53 +0200)
Similarly what we do with the firmware connection manager. This makes
tb_xdp_handle_request() return error to the remote host. However, we
need to make sure we keep the uuid alive so that we can reply until the
whole domain is released.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
drivers/thunderbolt/tb.c
drivers/thunderbolt/xdomain.c

index 34b7d18cce560cbdba2f2e8fa638fab0a7b188ba..677877baae6386b8213c0148d7f6e516b55ff8ee 100644 (file)
@@ -2952,6 +2952,7 @@ static void tb_stop(struct tb *tb)
                tb_tunnel_put(tunnel);
        }
        tb_switch_remove(tb->root_switch);
+       tb->root_switch = NULL;
        tcm->hotplug_active = false; /* signal tb_handle_hotplug to quit */
 }
 
index 4fe19cf6387dac6570b96f08bac1df600910045d..a1887a15a2849d8cc1d70cd4c0fac21acfdb122c 100644 (file)
@@ -740,7 +740,7 @@ static void tb_xdp_handle_request(struct work_struct *work)
 
        mutex_lock(&tb->lock);
        if (tb->root_switch)
-               uuid = tb->root_switch->uuid;
+               uuid = kmemdup(tb->root_switch->uuid, sizeof(*uuid), GFP_KERNEL);
        else
                uuid = NULL;
        mutex_unlock(&tb->lock);
@@ -880,6 +880,7 @@ static void tb_xdp_handle_request(struct work_struct *work)
        }
 
 out:
+       kfree(uuid);
        kfree(xw->pkg);
        kfree(xw);
 
@@ -2348,6 +2349,9 @@ static struct tb_xdomain *switch_find_xdomain(struct tb_switch *sw,
 {
        struct tb_port *port;
 
+       if (!sw)
+               return NULL;
+
        tb_switch_for_each_port(sw, port) {
                struct tb_xdomain *xd;