Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5364427pxb; Wed, 19 Jan 2022 17:08:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJx0EAyypca7rnYqSkoWotVxti9TtE8IBN1IAwNQJIcTYiCra7O2hqMDEuKj3YHdIq5Gns5Y X-Received: by 2002:a17:90a:4b46:: with SMTP id o6mr2980082pjl.146.1642640916735; Wed, 19 Jan 2022 17:08:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642640916; cv=none; d=google.com; s=arc-20160816; b=vvCPS5pqvcAsJV6mtboCqZPShZk4eReAs1LNarIoJ1CqHRGw4QIJbFIoDWUjNf5KI7 BbhC7XwQbFdjTdipOOKwJ2uTYUI4Ji7LEhu9AcKUu6euecA7fnmJFFcohfM7I+Om8DKY KxcR0jY/aDIukAXB959y3KCz1kGdmrwg3gAhX+ilQFcS41IVROCobMqYO8rt13hUR9tG 62BIhBmju6xi1QoJxfw3e4UisUVmhlokwRPwZ5aHEMUYf/LfEfl5sNOI7gymJ8Dl3cKI vq0uwj85uB8rPpxilNm26MJ2JTEh5xgY9xADwK2X9+wN4WvBgGDvq+WCAkqIiRQNDVBQ RYgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=oatsOPVN92hdmKd/7cOrPGnVc0uB/vChQPxqp3JkfTw=; b=QW7LLoMXO+nzeE3iVOv/DsAxNLtbM4mBuKNgpnZH40ZuxqCQ8EdoByJjfy3gJZ14Xo 5HdebVs8RPYKdNFt6Ar0k55tIKxQ/BhFfuy9GR7nVZvIfvTH56pmvXTgcYxO+hNK2Mji /KJIfyhpx+Z6Y0BHwy2fPzGTOi98to5aaPpXSZKUe9J5eVHC13+qkoG+2fLdnukHG/hg NYQmrjBg5+zYBKlHm/8xvRCPPdch14jioWL1FMZfHZ/yzRFFRv5ivgZbCWhhILIchamz xPnrTosq8XX47C/8SxE3BJlYOr0jM88SsNRfA7S7wACClk3n6bSt4/fi5nOwRXOT8FRC Vf/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="dCnX/rjW"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j12si2019577pgn.296.2022.01.19.17.08.24; Wed, 19 Jan 2022 17:08:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="dCnX/rjW"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345073AbiARJgT (ORCPT + 99 others); Tue, 18 Jan 2022 04:36:19 -0500 Received: from mga09.intel.com ([134.134.136.24]:22223 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240673AbiARJgS (ORCPT ); Tue, 18 Jan 2022 04:36:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642498578; x=1674034578; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=KOITIXo9rTTKwEPZruFQPM233i/+GJkiKbootFZI4Yk=; b=dCnX/rjWjXqd+Oq7IjcTE/TuNFmeA7fkbzVF4Lm0pfCzp7mvh1te/2Yz 4WrmvKcqrBvWvlKzYbNfGtJ1WbDLTKgJxX7xtw0YB1ZC6b9/gqKP8zbLc wg6Xi4hFiO1b5EyfckInLFTnnmWxPePm94FxRO/DX8HxLoibQ4uSSW7us Llmew3Yt7FGhRYqAuX8gg8xYvo3/fcG/xv7uJ83FWhiHGXlwLLizitjIc IL248D2JrCi8Uu0nQH+CmrVINVz359+h4KYMVqb3kYZa9JcZKXCDSCZpc WSglrx1tdcrktHjrFP27PcDzV8FDZBcPtM7kaeDZWG9KmFNo6/qXh062q g==; X-IronPort-AV: E=McAfee;i="6200,9189,10230"; a="244572557" X-IronPort-AV: E=Sophos;i="5.88,297,1635231600"; d="scan'208";a="244572557" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2022 01:36:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,297,1635231600"; d="scan'208";a="671790221" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 18 Jan 2022 01:36:15 -0800 From: Heikki Krogerus To: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Robert=20=C5=9Awi=C4=99cki?= , Mikhail Gavrilov Subject: [PATCH] usb: typec: Only attempt to link USB ports if there is fwnode Date: Tue, 18 Jan 2022 12:36:27 +0300 Message-Id: <20220118093627.74098-1-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The code that creates the links to the USB ports attached to a connector inside the system assumed that the ACPI nodes (fwnodes) always exist for the connectors, but it can not do that. There is no guarantee that every USB Type-C connector has ACPI device node representing it in the ACPI tables, and even if there are the nodes in the ACPI tables, the _STA method in those nodes may still return 0 (which means the device does not exist from ACPI PoW). This fixes NULL pointer dereference that happens if the nodes are missing. Reported-and-tested-by: Robert Święcki Reported-by: Mikhail Gavrilov Fixes: 730b49aac426 ("usb: typec: port-mapper: Convert to the component framework") Signed-off-by: Heikki Krogerus --- Hi guys, Mikhail, I got confirmation from Robert that the patch fixes the issue. thanks, --- drivers/usb/typec/port-mapper.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/port-mapper.c b/drivers/usb/typec/port-mapper.c index 07d307418b470..b6e0c6acc628c 100644 --- a/drivers/usb/typec/port-mapper.c +++ b/drivers/usb/typec/port-mapper.c @@ -56,6 +56,9 @@ int typec_link_ports(struct typec_port *con) { struct each_port_arg arg = { .port = con, .match = NULL }; + if (!has_acpi_companion(&con->dev)) + return 0; + bus_for_each_dev(&acpi_bus_type, NULL, &arg, typec_port_match); /* @@ -74,5 +77,6 @@ int typec_link_ports(struct typec_port *con) void typec_unlink_ports(struct typec_port *con) { - component_master_del(&con->dev, &typec_aggregate_ops); + if (has_acpi_companion(&con->dev)) + component_master_del(&con->dev, &typec_aggregate_ops); } -- 2.34.1