diff options
author | Mika Westerberg <mika.westerberg@linux.intel.com> | 2020-05-08 10:55:03 +0200 |
---|---|---|
committer | Mika Westerberg <mika.westerberg@linux.intel.com> | 2020-06-22 18:58:20 +0200 |
commit | 75ab3f06a1eb1dc0b45ba4c788cb5086ba138d85 (patch) | |
tree | 639d4c5eeb20ea601d2e8b03c1ff62c51aea94a3 /drivers/thunderbolt | |
parent | thunderbolt: Check that both ports are reachable when allocating path (diff) | |
download | linux-75ab3f06a1eb1dc0b45ba4c788cb5086ba138d85.tar.xz linux-75ab3f06a1eb1dc0b45ba4c788cb5086ba138d85.zip |
thunderbolt: Handle incomplete PCIe/USB3 paths correctly in discovery
If the path is not complete when we do discovery the number of hops may
be less than with the full path. As an example when this can happen is
that user unloads the driver, disconnects the topology, and loads the
driver back. If there is PCIe or USB3 tunnel involved this may happen.
Take this into account in tb_pcie_init_path() and tb_usb3_init_path()
and prevent potential access over array limits.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Diffstat (limited to 'drivers/thunderbolt')
-rw-r--r-- | drivers/thunderbolt/tunnel.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/thunderbolt/tunnel.c b/drivers/thunderbolt/tunnel.c index c144ca9b032c..5bdb8b11345e 100644 --- a/drivers/thunderbolt/tunnel.c +++ b/drivers/thunderbolt/tunnel.c @@ -124,8 +124,9 @@ static void tb_pci_init_path(struct tb_path *path) path->drop_packages = 0; path->nfc_credits = 0; path->hops[0].initial_credits = 7; - path->hops[1].initial_credits = - tb_initial_credits(path->hops[1].in_port->sw); + if (path->path_length > 1) + path->hops[1].initial_credits = + tb_initial_credits(path->hops[1].in_port->sw); } /** @@ -879,8 +880,9 @@ static void tb_usb3_init_path(struct tb_path *path) path->drop_packages = 0; path->nfc_credits = 0; path->hops[0].initial_credits = 7; - path->hops[1].initial_credits = - tb_initial_credits(path->hops[1].in_port->sw); + if (path->path_length > 1) + path->hops[1].initial_credits = + tb_initial_credits(path->hops[1].in_port->sw); } /** |