Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4748849pxj; Wed, 12 May 2021 12:19:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2/epr4SgankxdTq5mlbSMhwHMpeBW/PhQSNhcsgkAj7cza8ae6D1mlsa4DSoilZytRrj4 X-Received: by 2002:a17:906:f210:: with SMTP id gt16mr38975108ejb.52.1620847193027; Wed, 12 May 2021 12:19:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620847193; cv=none; d=google.com; s=arc-20160816; b=zHc5b8lD76ywNChsa+C0w22nQgfm4Y8cf2qUhVIsFh8BffGmDBdtaO34RW64qlXc/c 5i5r77IPPGAJ9n59ydCvKpcXw47zUmyCbps/TCyi/BAZDLGWc+GE3mb0wfGzpRIV+hY1 yfND8eaZ2pR54mcewLFB8cW/jG/4RanhzK01JQzMGzj2oMv/rA3N3bmWeSPtRVOXsM0B XzRWZkJLGUoZJVjzM1d74Ce+i/W1Usa0js5nLtfZCqMSgqYgYqhYucofO8rQzuL4p0Nv HMCN/hzRI8OCXc3sxLyBnd2GOwfHP1Kbm7LokI2n6epmovv1Av8Ni/wIjW6GUDBKI5vo HVEA== 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=pbl6/PSgYIP1uC4LU18JCvedV4LO4sLekY7dl9y10Q0=; b=amTwZA2reKeBbEP7qteeEuMmpxIqTinjr/3fOf4Yba1X+1Rw5g5D5olgyQ16W2PbXt iny59ihjVb14w/sTkkkynZDonp1zWbbEyojS/Q1ho8GoqA43UrmZiZqNN31gc05NH9nt ao7N8o8MXf0c7TiBGxpZpMr6z08EgnXjsIWsAfjaBy15n0qdcBF6M+rnCGJHRYjsmJ03 iYbbCWgLsUK7GAKMpoczm3nW4JRume+9inRdcGNarvlrwQO7L7STakfIyqSjDOlVoC9C sJXWvRahmh+YdTWzeK4hQMGD7P4VlmV0MaaScnIsIMX0dY+tMgZPjt+CpOzB4vJNrrpb saFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EPIcwReW; 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 i11si493600edk.574.2021.05.12.12.19.24; Wed, 12 May 2021 12:19:53 -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=EPIcwReW; 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 S1378281AbhELTLD (ORCPT + 99 others); Wed, 12 May 2021 15:11:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:39792 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236374AbhELQn5 (ORCPT ); Wed, 12 May 2021 12:43:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 89B6861E68; Wed, 12 May 2021 16:14:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620836042; bh=Yi7a76Xqz2dyROR/LuHq02uv2UfJ5IpCohE1rMnHwTY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EPIcwReW/tCL8JIfH6EP65l/mKMVs4ZE13b0n4j8IV1uwsDq4WWYggvwyHGVTA91w e52yy9y3AP7DSLZLoUQjX7BH597EtysrpyiEzkmlNiLsL00hgfAPwMTMRMX6El76RG cK99O7W2m2gaRyT30dTfJdOZGiZtOiDNTyvwx+fk= 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 5.12 586/677] powerpc/pseries: extract host bridge from pci_bus prior to bus removal Date: Wed, 12 May 2021 16:50:32 +0200 Message-Id: <20210512144856.852247618@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144837.204217980@linuxfoundation.org> References: <20210512144837.204217980@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 f9ae17e8a0f4..a8f9140a24fa 100644 --- a/arch/powerpc/platforms/pseries/pci_dlpar.c +++ b/arch/powerpc/platforms/pseries/pci_dlpar.c @@ -50,6 +50,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; @@ -76,7 +77,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