Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp319067pxj; Thu, 20 May 2021 10:02:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz89fgEbGUbjzuUDgvQQPyr6oVHH6E0ksLETivXnYOwzz9EZFLzqsP0/b++ZjlPVS3aIaqS X-Received: by 2002:a17:906:3615:: with SMTP id q21mr5737839ejb.414.1621530154241; Thu, 20 May 2021 10:02:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621530154; cv=none; d=google.com; s=arc-20160816; b=KsknjUs2W3E/nH+D7M28VychafHlEDYEeUGKPrsGzY41bpOHRLwNzHa37MmougWbsg jiWaPkos4yjqXsaRakUCkOZc+uFwXb6kdNfaDYI4cqmHU86y5Jr9i6Apywv5YmhGJWbe p/LR4VNx7qXVD4PKCTfZZ0bMW5mKTWHzkjtjIJ8MQxyqeJhy/trO7MZaoqa88rDnhHQS dhgYF0O5Rl426TQZVHU+R/aPFs2IkONHwmTtiLDOKAzy4yGqKyBUp0RgkAowwlVaRDJ2 OP1iO5o4xvXKEotjTDrSeCYqASnlBXDLbHVDpZKMUftjM8FKh0fV7BzW7zq3oredW/Qn CHVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZXTNLC7SkzJ1Mp0HkJldsVFL+ZXe8JuWSl6qLop7EVM=; b=MxJE9oKBjKaOjbjy7GRVXgdoKA0g3/EYHR9kXfDZpcL3v/9hHrtVCGIeJ9Q7utRCpm jbznXXpP4Eq+s+FXKLNiwp5u28EJfJi4V/yULeNLpyWOdvO7YCiGnItDG/hy0KxGPQx7 AjBKrSaKCNV/Yl2eX+FbsIjXtpLXwLDELgdCzl0pnzGZql1AzRP13QSYr+3lH9xjwvVu 8SDz9STFQShqE9KRfCPi2mEs2EYb9iKOe9/sm/IctzFb+ofeJfIJbvHiu/msZ3ES3xrg aVifzOfv77r9eqg/QazKXSYqvRtcG2TW4ux+ee+mDKiLoTzWKWZh26USLC3GeHlYcRad Wezw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Bs16JvNr; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z26si3469266ejc.46.2021.05.20.10.02.09; Thu, 20 May 2021 10:02:34 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=Bs16JvNr; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235762AbhETKJJ (ORCPT + 99 others); Thu, 20 May 2021 06:09:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:60694 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234814AbhETKBE (ORCPT ); Thu, 20 May 2021 06:01:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C40C16141C; Thu, 20 May 2021 09:39:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503555; bh=983Ah+4uJzy0J/+o/pgnIF8hsb2hAolKtyeeyHhuRTs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bs16JvNrDbd+iLkVMv4sWiyW3XeQEkBJWGtDlUXbdO+0HstOiHKG+c0szHhxj6OYi oU1LwV8Uij63f8Ao2tNUFta3vqyvj6GpA97R/hgziSRdbQs9Y8/dGJm4gMPB82xqsX 9GdzhqQOji92Ujrh8cR3BUnZTGAqEg1wuRvn5lhU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tyrel Datwyler , Michael Ellerman , Sasha Levin Subject: [PATCH 4.19 274/425] powerpc/pseries: extract host bridge from pci_bus prior to bus removal Date: Thu, 20 May 2021 11:20:43 +0200 Message-Id: <20210520092140.444797251@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tyrel Datwyler [ Upstream commit 38d0b1c9cec71e6d0f3bddef0bbce41d05a3e796 ] The pci_bus->bridge reference may no longer be valid after pci_bus_remove() resulting in passing a bad value to device_unregister() for the associated bridge device. Store the host_bridge reference in a separate variable prior to pci_bus_remove(). Fixes: 7340056567e3 ("powerpc/pci: Reorder pci bus/bridge unregistration during PHB removal") Signed-off-by: Tyrel Datwyler Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20210211182435.47968-1-tyreld@linux.ibm.com Signed-off-by: Sasha Levin --- arch/powerpc/platforms/pseries/pci_dlpar.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/pseries/pci_dlpar.c b/arch/powerpc/platforms/pseries/pci_dlpar.c index 561917fa54a8..afca4b737e80 100644 --- a/arch/powerpc/platforms/pseries/pci_dlpar.c +++ b/arch/powerpc/platforms/pseries/pci_dlpar.c @@ -66,6 +66,7 @@ EXPORT_SYMBOL_GPL(init_phb_dynamic); int remove_phb_dynamic(struct pci_controller *phb) { struct pci_bus *b = phb->bus; + struct pci_host_bridge *host_bridge = to_pci_host_bridge(b->bridge); struct resource *res; int rc, i; @@ -92,7 +93,8 @@ int remove_phb_dynamic(struct pci_controller *phb) /* Remove the PCI bus and unregister the bridge device from sysfs */ phb->bus = NULL; pci_remove_bus(b); - device_unregister(b->bridge); + host_bridge->bus = NULL; + device_unregister(&host_bridge->dev); /* Now release the IO resource */ if (res->flags & IORESOURCE_IO) -- 2.30.2