Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3502313pxb; Mon, 24 Jan 2022 10:54:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJytYEA2IqiwHM69arw0F+I8zXi3BXMzMQwncMCo9eULiJnpu69SqAzX8TrcrzbNiaE517Jn X-Received: by 2002:a63:b905:: with SMTP id z5mr12742952pge.245.1643050457527; Mon, 24 Jan 2022 10:54:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643050457; cv=none; d=google.com; s=arc-20160816; b=xnDTPNRt0tWoWDTbN8yhyeDYP6XCuG3EVaz5zEYhlREJUuk9iQOjXDATtslf7J8Vyq gVk07nJ4oyNyiYyjXgORD6HTpY3YxzlIw840+YOKcWgpm3LVdzuJYNUByz1iRESVopyS /9UYQLF905TqU3Mi+1ED0yvvjxIEj626xkQ6b+bJ2RvG7xV0jVXRkFeeC9YFLND/EZDL MUnJ2GUNtzHJXYcgbrOlyek04ob8P19JmU8bkaaB6W76x7OUlTkC07vx5Bg1jQqvR23r QMxYx4t7s9Uet9SN84lSoWnOH4Ag/umeMuhC6odzV3mj7VNJGSUrJovZuLwa9ynHkn+V wKvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=s5JCyb/8Ws5/exjuPcNrd5N5cWGlrx7oC8YgYjB6/6E=; b=TVyM1HW8KIey+p2lNxPfcOB/jc4RLXtigl5FDLbPKMnVir2EfB1qzk8mieCHzv5qll EL3Y4RyTPIhseWuty69EJVD2gMB5JL3Izu+3i1+kDAmr6TTHQzcfF8YAgtvf9mVlmp/c YJd5+Gg0fUC6M3f4V+QKmjH448X3Nz2/zy5lkLEqxhp1Yw2KUxt9zZ9QkAGNohIsdUB3 7kThsZ2lBQkhpkvNlJXwigMAb3AnMk4wcCxAa7iJLEIVbefMxmvNlCcjvY7HRzNpe6TL LLxtva07KRSfEHZeUvG3jWoVQRGTEojqQjP4CW5Meogym+9hb53ksmZWKtH+iyNyWkNT ZoDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FO4O4sd4; 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 h6si14837787pfi.262.2022.01.24.10.54.05; Mon, 24 Jan 2022 10:54:17 -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=FO4O4sd4; 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 S242493AbiAXIzL (ORCPT + 99 others); Mon, 24 Jan 2022 03:55:11 -0500 Received: from mga07.intel.com ([134.134.136.100]:19950 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242477AbiAXIzK (ORCPT ); Mon, 24 Jan 2022 03:55:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643014510; x=1674550510; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=B7mRVQn3mGN3EOaG2zxuvdC0hKN77JXTeveSRmb0/ZQ=; b=FO4O4sd4KL/7iz7SjW8782ijhREtC042mS4H30znv+TuqxG/dh7ZLgSc Umbmr5mHNkGtZBGuQjzY0keVjLatmOZTyaguA4bTEXnPMJvtpplZGKtUv 8DR1QCDkyDCKIvsYrvOoWraBAF7ws6ERoCT4iMY0pNQRaGNHNBhtXiaC4 KImH7yZFB5CGJ1NWmtKlDWqR9WQIbv+5eXqn8MW9KwnMjpeBVp6egI+P6 C6lcEr+wj1U8oEVwiE23+X/2VgTUTZ5UKgROSsZdi8LKm36xgy2PXr20Y eoOxzoOoHbWblCGVuCQza3HwSqeSU6H5mlJIKDtjdboFTvxpFYWizXZ56 w==; X-IronPort-AV: E=McAfee;i="6200,9189,10236"; a="309320373" X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="309320373" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2022 00:55:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="673558970" Received: from kuha.fi.intel.com ([10.237.72.185]) by fmsmga001.fm.intel.com with SMTP; 24 Jan 2022 00:55:00 -0800 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Mon, 24 Jan 2022 10:54:59 +0200 Date: Mon, 24 Jan 2022 10:54:59 +0200 From: Heikki Krogerus To: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Robert =?utf-8?B?xZp3acSZY2tp?= , Mikhail Gavrilov Subject: Re: [PATCH] usb: typec: Only attempt to link USB ports if there is fwnode Message-ID: References: <20220118093627.74098-1-heikki.krogerus@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220118093627.74098-1-heikki.krogerus@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 18, 2022 at 12:36:27PM +0300, Heikki Krogerus wrote: > 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. I'll resend this togher wit the other fix. thanks, > 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 -- heikki