diff mbox series

[1/5] thunderbolt: Bond lanes only when dual_link_port != NULL in alloc_dev_default()

Message ID 20210607110030.38664-2-mika.westerberg@linux.intel.com (mailing list archive)
State Accepted
Commit a0d36fa1065901f939b04587a09c65303a64ac88
Headers show
Series thunderbolt: Support for Intel Alder Lake and improvements | expand

Commit Message

Mika Westerberg June 7, 2021, 11 a.m. UTC
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: 54509f5005ca ("thunderbolt: Add KUnit tests for path walking")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/test.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/drivers/thunderbolt/test.c b/drivers/thunderbolt/test.c
index cf34c1ecf5d5..ba5afd471766 100644
--- a/drivers/thunderbolt/test.c
+++ b/drivers/thunderbolt/test.c
@@ -303,18 +303,18 @@  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->total_credits *= 2;
-		port->dual_link_port->bonded = true;
-		port->dual_link_port->total_credits = 0;
-		upstream_port->bonded = true;
-		upstream_port->total_credits *= 2;
-		upstream_port->dual_link_port->bonded = true;
-		upstream_port->dual_link_port->total_credits = 0;
+		if (bonded) {
+			/* Bonding is used */
+			port->bonded = true;
+			port->total_credits *= 2;
+			port->dual_link_port->bonded = true;
+			port->dual_link_port->total_credits = 0;
+			upstream_port->bonded = true;
+			upstream_port->total_credits *= 2;
+			upstream_port->dual_link_port->bonded = true;
+			upstream_port->dual_link_port->total_credits = 0;
+		}
 	}
 
 	return sw;