From patchwork Mon Jun 7 11:00:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Westerberg X-Patchwork-Id: 12303147 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7845C47094 for ; Mon, 7 Jun 2021 11:00:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A149560FDA for ; Mon, 7 Jun 2021 11:00:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231209AbhFGLCC (ORCPT ); Mon, 7 Jun 2021 07:02:02 -0400 Received: from mga09.intel.com ([134.134.136.24]:4781 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230507AbhFGLCA (ORCPT ); Mon, 7 Jun 2021 07:02:00 -0400 IronPort-SDR: vfuot7jVB7SAr2+DJbSSwfV/Zp/HdpvbMViLyW0rUh0bxnHn2CX9mTkycKdtoeM8MJkYLEwedp oaTUFUW2jd+A== X-IronPort-AV: E=McAfee;i="6200,9189,10007"; a="204569300" X-IronPort-AV: E=Sophos;i="5.83,254,1616482800"; d="scan'208";a="204569300" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2021 04:00:09 -0700 IronPort-SDR: MpE/U940CBhjR4xeXMPmE2XHOv6YCGTbbvwFpc9zY//kmHpkj1AXnBWek2hoKnQBhl59Fv5t32 NhlXTvIuH2vA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,254,1616482800"; d="scan'208";a="413000837" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 07 Jun 2021 04:00:06 -0700 Received: by black.fi.intel.com (Postfix, from userid 1001) id 5AF4B67; Mon, 7 Jun 2021 14:00:30 +0300 (EEST) From: Mika Westerberg To: linux-usb@vger.kernel.org Cc: Yehezkel Bernat , Michael Jamet , Lukas Wunner , Andreas Noever , Mika Westerberg , Dan Carpenter , kernel test robot , Gil Fine , Azhar Shaikh Subject: [PATCH 1/5] thunderbolt: Bond lanes only when dual_link_port != NULL in alloc_dev_default() Date: Mon, 7 Jun 2021 14:00:26 +0300 Message-Id: <20210607110030.38664-2-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210607110030.38664-1-mika.westerberg@linux.intel.com> References: <20210607110030.38664-1-mika.westerberg@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 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 Reported-by: Dan Carpenter Signed-off-by: Mika Westerberg --- drivers/thunderbolt/test.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) 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;