Received: by 2002:a05:6520:4211:b029:f4:110d:56bc with SMTP id o17csp2118672lkv; Thu, 20 May 2021 03:51:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWHCI6pkbvV2PZXoDp7pnq3Pua/b7bykWvdy6dv5AET0BEXQDdj3u/LLvQ0Q/S/22cf6K2 X-Received: by 2002:a05:6402:358a:: with SMTP id y10mr4166270edc.65.1621507882708; Thu, 20 May 2021 03:51:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621507882; cv=none; d=google.com; s=arc-20160816; b=ImP0/JIQUjXkJg2iNZUQiZDpyhOWw6dOx8vj3K/n4KZvOMY15RRRZyKalBpdQbMzo7 agLDwk24YpDqIFPQh12BI70xzAYnckTwSpvn0sdJ0NMA45Eu9Eo2hf+BtFlFp1YZj94g GiAgXEFK+MsiFjfMWhuz0fJhaiudN9efQQFHZKS0BQilMFlWzY/JpnqluJ83bwVn0rLi c1tYK1reNmvFjAhvGR86joGyAlAxXd4DG/5kYHqWp3Sfab/QEvO06CgdrocwpJ9kbN4A 8QEgsLBKL+g+SeGcZ5LrDzq2/bdOKgH3H0jhCXo176tfCz1Z30XE0Oofs4lz5adYrLl5 j/KQ== 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=Wuf4Mr1tziqWQKf3uCD6qe926WdGrBqP86KEQ2L+MHYVAjNH6pxhgNt/qQJKcstT/o iDK6qaA7k0qwUkWhcyAuUyqrAv9jkPVIeEI/tlzpASVPZtLaIotLiVguMntZzu2jRp65 ZWt2C7s7PsqFOk1uoK2sb7XzPQt23atKuYJKDPKEh41LwkDZV4Erxa1h1uZ4QNNifuJV PaguMAduDVKDMi8xJWUpuEUzZfTWvYeTXY2d3DAyFBAAhWxxILtLHTMKpTH4smk0ItRo ikm5CMIfTn7RBrkGTbe+h6FDldOtCLmw9Kn7RIxESUhy0Shwx+pmkNVTjLZ0Y6aUqSih sDqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cRJJvukB; 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 z25si1705162edx.141.2021.05.20.03.50.53; Thu, 20 May 2021 03:51:22 -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=cRJJvukB; 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 S236931AbhETKsv (ORCPT + 99 others); Thu, 20 May 2021 06:48:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:60392 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237327AbhETKdb (ORCPT ); Thu, 20 May 2021 06:33:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2F41461C4C; Thu, 20 May 2021 09:52:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504371; bh=983Ah+4uJzy0J/+o/pgnIF8hsb2hAolKtyeeyHhuRTs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cRJJvukBC5LzdwRk++t1dRYX6o5id6iaVwQ9d4nI0VEhrAnQGiaJN/cxuD7s5sE0w /4KT1AS7d0p2J6WXBKlOKbUeOzohxInBgWCC4Si5mC/DYFihi599mK2mxsSLTMwzse 6jJ+bssbJKyBlxU2/7Ak9NGPIHPZjdpmAAzn16Zw= 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.14 216/323] powerpc/pseries: extract host bridge from pci_bus prior to bus removal Date: Thu, 20 May 2021 11:21:48 +0200 Message-Id: <20210520092127.535184080@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@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