Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp732491lqh; Sat, 4 May 2024 22:45:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUdcUtktmjVXUinackXrqNEtx0X3dtBsUONjQyticx0FRphcc2wOUls97ETL9YC1vBLd+stplAhXxg7qNcd1zU6nWvLeE56oKOk646gKw== X-Google-Smtp-Source: AGHT+IE6JopuBFC9A3b88a0QympDeFzycGSO5HXtvaZNC3FEanD1BzTdvUWRajbmdJI8y5PJkx+i X-Received: by 2002:a05:620a:2a07:b0:78f:1bd4:6906 with SMTP id o7-20020a05620a2a0700b0078f1bd46906mr10788323qkp.18.1714887928394; Sat, 04 May 2024 22:45:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714887928; cv=pass; d=google.com; s=arc-20160816; b=xk37hzHQSwbsXc1elp78s4JbWbIAu6fNPiJQhywBU2hrmxw2eDeV31iicmPxEby6x3 ChXkgvIhgr+S2EneRKHWDJSTO0zuXJVcigYPCn1X1tIzkt9i5VNL+T09t4nyrDnWv4Xr 3wovFYKdnJSR867xZInWogz5lVtfvKb7cI90HR0uWds3L3vBjFtan0fQfZUh4mN7d8NH 1acqPPgF4FjiVVsjIFBRMPqGbLc+eMclHelkQhgjN9Ikd8mD1TlEprdvzLKWnQ36U4Lx UfaWLXKdwTMOR/lKxrow+wkFHS5f1ymFEOSEGeiOo4I3fUlzmjQupP9o/2fnVj956DjW mHEw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=KezoY1hyJXHst4lYMQa5iHkk/IUH1TzJZVk2MrWXInY=; fh=eKlJm+6MHGZ3vlpGJkFGvOyGgOn78oWwcsxV52yyaCM=; b=otc1ryh78It/mq1oIOedmr50um24yaQWIonKo+N3ZIIEHjmoC6gk8tQd+pYh582VAS Ijylo/c6UmkVYMZ2nT+YgizGR7tPSvI9LRnQnHlHVjd3peT1FtlbSA4RqlL6mRYFDn2f VCw/4fG4OMCJkqwv1C255/5toWdBeGn8LPWL+JPvatGV5b3KUgBC4z06Idok44oQEam3 Tx/kKglTqJhgIqoU6K3ZUdcs8X/d+HxeAh/P+vp+SFTPpQB+loKVh3EW4wbhBGJWreIn sekdUoBT2MJ9fHJh6A5412P+WZTW2XrIyspYLWDgdszHC2kmakAuokrQ1kZD/tbBcxpy FEfA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-168896-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168896-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id bp13-20020a05620a458d00b007906cf26b63si7261111qkb.582.2024.05.04.22.45.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 May 2024 22:45:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168896-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-168896-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168896-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 225721C20AD8 for ; Sun, 5 May 2024 05:45:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B3D443FF1; Sun, 5 May 2024 05:45:20 +0000 (UTC) Received: from bmailout1.hostsharing.net (bmailout1.hostsharing.net [83.223.95.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 252461878; Sun, 5 May 2024 05:45:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=83.223.95.100 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714887920; cv=none; b=K8EdV1gNNH+Y+gQM7SSaXYubRWZ/0ffaQJ4ju3WRh4LJD/9jU12muXMZxbrwfhugEmldMkXwEXOjpHU5tZQoPqeKaPTUHOuJU0G7TEAlmrtuOWhDCCbHTMvhz1MW+Az3PT0/l0MuwzoVRg5+Oo/uepXoGTee3rIRQoVTCJ+ieVE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714887920; c=relaxed/simple; bh=iKYqSQ0o1WVtotuE2t0+4AkmIWAyJXmh3LblzVQCMNQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Z+9rcbgqo8mVYITozalu1Ge/apww+gUDBZiSLKulxoQ/O6FvqPz2xe28MClcN3AKijA5zOayJa72DDPjTut3cmUvWkYwTE2HI7sLHlJYV71b1I2a01AnwBfE8hp1x0lGFHsDUAQf1Az4DIYwimPKRJ1MW8btSgM5xQ25aKZyq3g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=wunner.de; spf=none smtp.mailfrom=h08.hostsharing.net; arc=none smtp.client-ip=83.223.95.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=wunner.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=h08.hostsharing.net Received: from h08.hostsharing.net (h08.hostsharing.net [IPv6:2a01:37:1000::53df:5f1c:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "*.hostsharing.net", Issuer "RapidSSL TLS RSA CA G1" (verified OK)) by bmailout1.hostsharing.net (Postfix) with ESMTPS id B363C30010C93; Sun, 5 May 2024 07:45:13 +0200 (CEST) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 708A448D1A4; Sun, 5 May 2024 07:45:13 +0200 (CEST) Date: Sun, 5 May 2024 07:45:13 +0200 From: Lukas Wunner To: Nam Cao Cc: Bjorn Helgaas , Yinghai Lu , Greg Kroah-Hartman , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Ilpo =?iso-8859-1?Q?J=E4rvinen?= , Mika Westerberg Subject: Re: [PATCH v2 2/2] PCI: pciehp: Abort hot-plug if pci_hp_add_bridge() fails Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: [cc += Ilpo, Mika] On Sat, May 04, 2024 at 06:15:22PM +0200, Nam Cao wrote: > If a bridge is hot-added without any bus number available for its > downstream bus, pci_hp_add_bridge() will fail. However, the driver > proceeds regardless, and the kernel crashes. [...] > Fix this by aborting the hot-plug if pci_hp_add_bridge() fails. [...] > --- a/drivers/pci/hotplug/pciehp_pci.c > +++ b/drivers/pci/hotplug/pciehp_pci.c > @@ -58,8 +58,10 @@ int pciehp_configure_device(struct controller *ctrl) > goto out; > } > > - for_each_pci_bridge(dev, parent) > - pci_hp_add_bridge(dev); > + for_each_pci_bridge(dev, parent) { > + if (pci_hp_add_bridge(dev)) > + goto out; > + } > > pci_assign_unassigned_bridge_resources(bridge); > pcie_bus_configure_settings(parent); Are the curly braces even necessary? FWIW, the rationale for returning 0 (success) in this case is that pciehp has done its job by bringing up the slot and enumerating the bridge in the slot. It's not pciehp's fault that the hierarchy cannot be extended further below the hot-added bridge. Have you gone through the testing steps you spoke of earlier (replacing the hot-added bridge with an Ethernet card) and do they work correctly with this patch? Reviewed-by: Lukas Wunner Thanks, Lukas