Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp304221lqh; Sat, 4 May 2024 01:54:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVZBHX1RZkqzqeRdBf0E0382cHSV+rZ/lGzUkDrrYzoyeE9I6Il12m1VzbrwwPHyCkWM6fuKOy5vP1fxKaGISGPf113ZD3La/EIJPtulw== X-Google-Smtp-Source: AGHT+IF/hOssgH5jI4G9oRLK3X3qJaHGJ6V+Sjy6+wKUdSew3tg/+18MoQdR/eY0bX16Ji047M8/ X-Received: by 2002:a17:907:7087:b0:a58:7985:8eae with SMTP id yj7-20020a170907708700b00a5879858eaemr3198761ejb.76.1714812880387; Sat, 04 May 2024 01:54:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714812880; cv=pass; d=google.com; s=arc-20160816; b=UYCm9nCKgpr7BqpAA03QbGJHtVUH75YCjTztBHfiOocjM6inqBdUlvaCIDzeESadEg B4Mr6lFNZ3MDYVnx37oByzorIJXITRthMuqhHsXPpPF17FxQxggQ41SFEGYP5b60Cpww 975Lb/Fu11wm+Zp8YWiT07v6iBrp1fUXBnBP+kBTDWVMBME54LghcyHilrMEvduKnFlF K9KcZ2+T7+Ru9rIVCWF7ovfdrqa3H1STn0/vXHM4bPqBQiz/Y6SSJvQKxb1BhWbWN6pE 9axNzN7OvpvtiLlZZxjUn+cFRZrgW+cO6JnlUJ/H0vGTImBqbooZF0dxuyQ3s9mxaSeP HlFw== 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=XQmUVpLLPBAEiExMeicOYkoaoE5doFWIu0w/uAZWPU8=; fh=wQhH/Ip3KRi/trFKMirlOoRVyj87VZYub6ebQtblXVs=; b=OjN6v8exKL3Cy6lRdjq/fvchK1GJLLjOIf+YaGSUg76GbEEHuteNk6B8uHkL/KoTQi 3IvanS3eTUE9hEJfOjTf/J/c1jm0HNQazlNR1e/PTcNzlsY2Joe0xLZwBHTZ4dHb3jXd aPXlJgOC0SGAUf3Wwdprql2BsKLj3LztjvTKxp337B6oRtfRrNWIBu+57j8QuCjPOgzj nBoO5XFmLl/vKjNxN0cjdMce7X93Vp4bsWZYVczlNzwJ+7GGS1pLPpOZrByEYMKlh6dl WSKQ/7uVnlThKFcAAZNh94JJyfgK1Nnbr7F3/nEXVVuPdxh8XxG0wYhSjvleIWN/ucnz 8+tw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-168562-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168562-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id q9-20020a170906144900b00a598cf8f400si1702623ejc.944.2024.05.04.01.54.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 May 2024 01:54:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168562-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-168562-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168562-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 am.mirrors.kernel.org (Postfix) with ESMTPS id D2E601F21EFC for ; Sat, 4 May 2024 08:54:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F210D1401F; Sat, 4 May 2024 08:54:28 +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 5385912B72; Sat, 4 May 2024 08:54:23 +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=1714812868; cv=none; b=Tr1L3d9GssFEVTPaktqIwk71EDoOpMYUVYKo5h6fzqvL9tlmSRvob5vkmKizE5cL2f58lNSj8ZsvjRE9i9hkxUJkJscTsftuYohOfQ/AIuAWC4WbgdfL/iqFlROelEfe+sA075dhHQLmB+fkLtrCjeJhw2mSqjRSPC+z/LaFYW4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714812868; c=relaxed/simple; bh=by3XQQG8YFnDKF4C662orwTdpQvrT8yA1UTPsBBsQuM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EnGgzfMq3dHTNQmHvu+Og3Th2tsnYFSUaVnySATbL45HIdN7m40/xoy5JWG0L7mpo7mN4rJrsKbrOerVQhhz3VVYEP7i/WeNPSgDmM2U0FZUf8ykGEFjNewzshmunXc2jTGW2+NbD0J6BWaXcBnDDF0Pd/O1+wEdeFNAlDNZg4M= 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 C42543000E447; Sat, 4 May 2024 10:54:15 +0200 (CEST) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 9CF6148D184; Sat, 4 May 2024 10:54:15 +0200 (CEST) Date: Sat, 4 May 2024 10:54:15 +0200 From: Lukas Wunner To: Nam Cao Cc: Bjorn Helgaas , Yinghai Lu , Greg Kroah-Hartman , Rajesh Shah , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH 2/4] PCI: pciehp: bail out if pci_hp_add_bridge() fails Message-ID: References: <401e4044e05d52e4243ca7faa65d5ec8b19526b8.1714762038.git.namcao@linutronix.de> 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: <401e4044e05d52e4243ca7faa65d5ec8b19526b8.1714762038.git.namcao@linutronix.de> On Fri, May 03, 2024 at 09:23:20PM +0200, Nam Cao wrote: > If there is no bus number available for the downstream bus of the > hot-plugged bridge, pci_hp_add_bridge() will fail. The driver proceeds > regardless, and the kernel crashes. > > Abort if pci_hp_add_bridge() fails. [...] > --- a/drivers/pci/hotplug/pciehp_pci.c > +++ b/drivers/pci/hotplug/pciehp_pci.c > @@ -58,8 +58,13 @@ 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)) { > + pci_stop_and_remove_bus_device(dev); > + ret = -EINVAL; > + goto out; > + } > + } Is the pci_stop_and_remove_bus_device() really necessary here? Why not just leave the bridge as is, without any child devices? Thanks, Lukas