Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp32846lqh; Fri, 3 May 2024 12:24:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVaWseukleZqbOJ+h5MjPmY4rYa13Xtboszo1Z+olKFqAtw3sPBy3uDDy9UqFdUFK4NptUV6GaCCQQPCpW0hchSK/91LWJ8qa/YZ1HOiQ== X-Google-Smtp-Source: AGHT+IHYtTlJSpHmLMjOvwt6KGa2oCY2W2A4pXy31P7UTq17DbdxfZ2t/wR1XSqsJVyOQ4t5rctG X-Received: by 2002:a17:90a:2f62:b0:2b1:4e21:2c5c with SMTP id s89-20020a17090a2f6200b002b14e212c5cmr3408631pjd.49.1714764262140; Fri, 03 May 2024 12:24:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714764262; cv=pass; d=google.com; s=arc-20160816; b=BGRbSR4nIyTp3VyQJd13/zHRE1Wl8AV4aBBQ7AJkD7WKNOWyxSAss4DmNv6YQXr+ri /SJKVVyvwuZ13GfiBON9G+1XP6mP+CRoFlViDNneXlEAcIzzO8+KV2hl7rR8A8GSLNFn 8SGLtDqkH3qQnI8uCX1/TWQ4VmhIwUc99Q74l6AB7COLkZ+OPVg7RrNDvGGhQlRK1Ghw x01pMWWMraIdM8wYCTtJv/lKVK7gSB1Bn//vHGI2pX2qg6bjT3tHro6XBPt4dt/PV8pd 4GyN7nmLEqixHPtD31JyA4Hkb0CgbH8uYKv6J78ZrE4F7/D2QXU9oBdT3ihTBibwNsQ/ UiXw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:dkim-signature:dkim-signature:from; bh=N5jIEdIgaqgrxTScZMNamJ/VXpKyySn2wZ02dAazQ0s=; fh=9meKEgtIbaBFJaqARdWsxPqZDxLgf10IObszYR75ST4=; b=vRNw7HrR/wh0x4rnX+jFx8Fon2R0zcwe/9+raogCUS4ZrBVi5oKV65icGr2RUFHJIe wdXDht1+yEzv20vE55pFTtdgMt5SHIpo10lnNLAuDrojOFbf2GMICIDbpAPim2yKTjUP Dd659+fBv2DSa4IQl4mpRwgeX965z1OI1mOO8eia2kOE75fVMAbCn0f1nBvlwxmX7doy VDlH+oi/LtA3udnIF8XHN7m45eV6EB34mYviFJTqgPYLhsa+gPUNBpHv81Dk3SAWa92u X7moaPGVfI9Td7+cv/aovpwrg2ENIi06V2YZhc57BGX3tNCht8ePQyloOPpzcHOYnl73 3rew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=qkaadJiX; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-168113-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168113-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ob7-20020a17090b390700b002b32ba17a2fsi2813488pjb.64.2024.05.03.12.24.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 12:24:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168113-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=qkaadJiX; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-168113-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168113-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 9B4E6284B1E for ; Fri, 3 May 2024 19:23:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B9026158D69; Fri, 3 May 2024 19:23:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="qkaadJiX"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="4plJyvGC" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 9248F63CF; Fri, 3 May 2024 19:23:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714764209; cv=none; b=u1lIy7K4D0z2ieVKQwwhwY11CGo9mZLY9rYnLYP8TwdrJg1ge/tTKXUBJ9fNweocqOLZJzNhGJpo7h0ZKM7JNIgcMGmKm2ftVAHvM8Bd+tW/zLSN3qTmMjfVUYSeA1dZRBKPX/KFu773BzeBBiSXnxVVCcpw16yDUyjelS/lazs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714764209; c=relaxed/simple; bh=DaxfR4nd3a64EQUQw4NMPaAY0t4XypNnjDLYOANYiX4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DahePB4bENspD8oUgYnBcVi53r5p7JSGLRFbNMm9bs3f9j4MOnyetGp4/u8C/7v7dAVd//8kN7CsO4qCN4jE/b+E3JjFYVS6CmtP+Z0hKPXLb7JN7vVUZ9fazwBm5mBfmn0HfLLmPCRBGEmMANeh29dXQDl39b5LiTyJJtVf1bc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=qkaadJiX; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=4plJyvGC; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1714764207; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N5jIEdIgaqgrxTScZMNamJ/VXpKyySn2wZ02dAazQ0s=; b=qkaadJiXro9eyKM9NKF9MwCToGL7taF+8MDW9IJNbl7s9g86wSsxhnNnyaLos85G2f4F03 XEM9EqPGHsiChm4XX6NMa0TD8G58LDwkZtHqf5pK6P+s8ZzUisN/9GUjdrhpsnMsWqbRyT DR5JhUc213j9PF+ww3PpPFwwL4cHTR/Wdo1PkOOI0IQs5dzj1V8WHcuSeK/F8miPsOIEkl Op3s6L9RLEBm6lhK4cgT4xnSg5KjDfDFKDK/TSWACphS71lWwbFcoixcDJNjQmwEvCzkJh 9cftqoFthVUtKV+qhXmuYAqOWnhmh3EhL6wSRmELER5CQlAjsAGj6RInZgfGxQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1714764207; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N5jIEdIgaqgrxTScZMNamJ/VXpKyySn2wZ02dAazQ0s=; b=4plJyvGCzyfpMLlQEcJIOmsoajwdPs9a4JxmXMvg7I0l4o31erdjKmw0/wh6P35kcGlCJ4 /HIRlHM6JyJx7BDg== To: Bjorn Helgaas , Yinghai Lu , Greg Kroah-Hartman , Rajesh Shah , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Nam Cao , stable@vger.kernel.org Subject: [PATCH 1/4] PCI: shpchp: bail out if pci_hp_add_bridge() fails Date: Fri, 3 May 2024 21:23:19 +0200 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. Fixes: 7d01f70ac6f4 ("PCI: shpchp: use generic pci_hp_add_bridge()") Signed-off-by: Nam Cao Cc: Yinghai Lu Cc: --- drivers/pci/hotplug/shpchp_pci.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/pci/hotplug/shpchp_pci.c b/drivers/pci/hotplug/shpchp_pci.c index 36db0c3c4ea6..2ac98bdc83d9 100644 --- a/drivers/pci/hotplug/shpchp_pci.c +++ b/drivers/pci/hotplug/shpchp_pci.c @@ -48,8 +48,13 @@ int shpchp_configure_device(struct slot *p_slot) } for_each_pci_bridge(dev, parent) { - if (PCI_SLOT(dev->devfn) == p_slot->device) - pci_hp_add_bridge(dev); + if (PCI_SLOT(dev->devfn) == p_slot->device) { + if (pci_hp_add_bridge(dev)) { + pci_stop_and_remove_bus_device(dev); + ret = -EINVAL; + goto out; + } + } } pci_assign_unassigned_bridge_resources(bridge); -- 2.39.2