Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp34048lqh; Fri, 3 May 2024 12:26:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWejc5FzGMkazu1MM7N1vmNjMzgceoOC9utYfpIGlg6vRtKXZN3auxBRos+HF4Ld1x3qxg1vJHTZiHW2QolgEwmTOrrEeuAPiUDnOYiGA== X-Google-Smtp-Source: AGHT+IGlA4t4qwnrsFT0ooi0DdrWMK2FA5iMvcd3130tLb28vRQi1SwlO5Hi3J9c2adBaefFkf0i X-Received: by 2002:a17:902:fc85:b0:1ec:5f64:6e74 with SMTP id mf5-20020a170902fc8500b001ec5f646e74mr4977775plb.23.1714764413025; Fri, 03 May 2024 12:26:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714764413; cv=pass; d=google.com; s=arc-20160816; b=nclnueW1PfnqN7z6sjNRumzk6e6ge6Ducr2+gKBe6y8t2w/YoYOysZkkpZo3Siq2jE 3uRkTDUxZN7uL34YiTw0Kx+ku0Lu7IZxsz8gGjP7rfZuPBmPvUH2EpiCd6ltt/LwgC41 HZ7LZwC8eV+f6eoF1Kfn2mvdIkqo98gUY0aqh5FyLCN6v1fQda7evEq7KgPNjfKmaDq4 n5vgRxqpQZF/Rk8jt+X92DnfU7rJ4mccB0A2KOghS7F4tzpMIC3HeJ6BkfoeUvrYQbBs Ca2SblRJgr3OjHsd6s6oB6rOggzO26SKDFdxbgW0xwsCNze0Nz85aJIW1bSXjI1AvV9l FKmQ== 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=ufiKfNBkmRVUEcnLSYPA5RmeUW8wkmfMWjVab0qBmPM=; fh=9meKEgtIbaBFJaqARdWsxPqZDxLgf10IObszYR75ST4=; b=PwSgXIk5x3mwSKlj0cX73irTvGACScHfE6KyAp77hf19b0DVmyxtUdkH7hZosI6Ae9 BDEAb0Nf8/Pf6W/+j7c+zaZvNMi9n9VUdLOCf7/yaZrKTr5//GKUKVJz2FUm9Nqsc9oQ VUYZMlCWW0CFKhAl7cFKtxYxpC1t+VPkmXhRQ13lzhB0CqAhvK8NdHzF2KXAA0P1Ip/T TTwp6nt+L14k2+xxU67cVs+Vt4HYhVKm48iVtZ+/kUlhNQzgj/hRlWLxNV8pfZkxnHK0 y/dv4d0HNWRIHcR45qWfpk+V6Z/kSoqO9IZE2NjHN4cAk+wAiMV9sM1QDDNIHChzP+s9 3eGA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=NeDOZAmj; 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-168117-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168117-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id o9-20020a170902d4c900b001e2c3ace272si3626636plg.99.2024.05.03.12.26.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 12:26:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168117-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=NeDOZAmj; 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-168117-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168117-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 3F6C9B2105D for ; Fri, 3 May 2024 19:24:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7B9AB158DA2; Fri, 3 May 2024 19:23:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="NeDOZAmj"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="VPxKixfJ" 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 924DC158207; 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=1714764210; cv=none; b=frS5MJtPpP8ZnZlZxq80rwRJzm/9kwpPWksju4S3oM+hJ8GS2KC21AiImekUbq6ItejYMDEGOAa0TAUEnjKqqFFfTeCBsRI6dO/4DmphJgm9FWhEV9BpIOZ2Ll7cS1XVVQijwN6zjp36fv/foMQC5vXwDZj6Ua52zPWAqp5CXkA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714764210; c=relaxed/simple; bh=EZgwArsC5As5LlGORe/CHEXCKSnJoGIS819EFQm9qjE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=t9FwWkg2woVLE2gN8q7lnur/HjPyYvv97piG4AQ7rXRrUrtvL2LwSYw2J7DYd/qQPOjRuOPrOKyID0DZ+maTjjP544xw4h4WaL24iA46TMi7rXR2hyL63a5FU/IfP/ADV+/dYYMOqs3+XjgJA6j0bKJmK8LvPKxSXXErkFba8Q4= 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=NeDOZAmj; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=VPxKixfJ; 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=ufiKfNBkmRVUEcnLSYPA5RmeUW8wkmfMWjVab0qBmPM=; b=NeDOZAmjfeRDGVvGyg9BDMfEfamyyjqV+zIhaM7Dsd3ikXfinsEwSy/MKbLgEZUokEnOd1 LLm7pxP+TNLZhY9S2GdZgQzo8VDYDxFyJU61aFKVLr62+hDgVdYy0iJI6scgR5c24P1vme 3QXTY9G87RJfIleHy92yF0E6ZgVEnP1p9ST2sUN4VoPMh88DIFvKZMc1ID2D+eG1jGznYW NcpxWwAnS71sOByS+gGKP9BAGBne+ZbhqMjfetHmT09P6tHfUtoVsmukkd/Ju3vHFIy8f9 WmEwxfsEHkpaoD2FQvc1xVJWyY3hdGXhSa295By83UIni37ZoS89AHdL3Zhi8w== 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=ufiKfNBkmRVUEcnLSYPA5RmeUW8wkmfMWjVab0qBmPM=; b=VPxKixfJXauOKep5gVzWa3vFvxUpna+EBpNuFRfMz3J5UEJOk2Z85ZuzT69wyJ3yPd5J+q bmqbgveUUtNq8wBw== 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 2/4] PCI: pciehp: bail out if pci_hp_add_bridge() fails Date: Fri, 3 May 2024 21:23:20 +0200 Message-Id: <401e4044e05d52e4243ca7faa65d5ec8b19526b8.1714762038.git.namcao@linutronix.de> 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: 0eb3bcfd088e ("[PATCH] pciehp: allow bridged card hotplug") Signed-off-by: Nam Cao Cc: Rajesh Shah Cc: --- drivers/pci/hotplug/pciehp_pci.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c index ad12515a4a12..faf4fcf2fbdf 100644 --- 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; + } + } pci_assign_unassigned_bridge_resources(bridge); pcie_bus_configure_settings(parent); -- 2.39.2