Skip to content

Commit

Permalink
thunderbolt: Bond lanes only when dual_link_port != NULL in alloc_dev…
Browse files Browse the repository at this point in the history
…_default()

[ Upstream commit a0d36fa ]

We should not dereference ->dual_link_port if it is NULL and lane bonding
is requested. For this reason move lane bonding configuration happen
inside the block where ->dual_link_port != NULL.

Fixes: 54509f5 ("thunderbolt: Add KUnit tests for path walking")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Yehezkel Bernat <YehezkelShB@gmail.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
westeri authored and gregkh committed Jul 14, 2021
1 parent 36f6070 commit 2abfa52
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions drivers/thunderbolt/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,14 @@ static struct tb_switch *alloc_dev_default(struct kunit *test,
if (port->dual_link_port && upstream_port->dual_link_port) {
port->dual_link_port->remote = upstream_port->dual_link_port;
upstream_port->dual_link_port->remote = port->dual_link_port;
}

if (bonded) {
/* Bonding is used */
port->bonded = true;
port->dual_link_port->bonded = true;
upstream_port->bonded = true;
upstream_port->dual_link_port->bonded = true;
if (bonded) {
/* Bonding is used */
port->bonded = true;
port->dual_link_port->bonded = true;
upstream_port->bonded = true;
upstream_port->dual_link_port->bonded = true;
}
}

return sw;
Expand Down

0 comments on commit 2abfa52

Please sign in to comment.