Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp228152pxb; Wed, 25 Aug 2021 01:37:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyp/vSEuzsQ+m6M2blfP2axB55EfDICR5VY+0pT7rjubw9GhI80Mr2iU+cpNa65veCft25H X-Received: by 2002:a92:cc0d:: with SMTP id s13mr28274957ilp.95.1629880634510; Wed, 25 Aug 2021 01:37:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629880634; cv=none; d=google.com; s=arc-20160816; b=BE8qzPEUi6ijyjucdwAXs7lsCEZ5qEp/kTGJIBBbqXZEv/1mfrmp05svrA15U+qKjZ fgBThRQwbqa8Y2VWG0mVj7lZ3RDtYT0IMPoaA1zOuqR2EM1L5nkvo29DcoLgZ6um21UL uPwg8ZWAys1WBC8diM3l1QBB5SjPiNKg3FQMjp5wof6BoNxsfFdYR3yQkmDNWNBdxwqh aDNry1VzYl1rsI5Z66PCf13s24BCML9E27jA7X3kwncrWRO3kC3+L2OlZfSQXcSIpIln UsOLIdArzcg3jRgutM0vd9g3+WBodS82VKDS2ufX9f3AWPTnccb48L78ZIfuBQUGm7tk T4ug== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=nMKSuVzaG2Rrxo6b48p2rwBfxxJ2KT7SrwxgTpDKdz0=; b=RqV5tV8uIO9gL16dTmgycilKSDe7I1RjapErfvT7OuhwFjiWitsudVYm5OUzETj23l smsOo/t5VVTsqsu7EgMJMh1iryzlEudjOiRF7b14qu24+zns1QnOF8DAkRALX/KqRb1a v4vE7Pa2Ts0xR8kaxc7jU9JqP3WO2wN72Q4ZqRYR6iqn/3aOJiaRqk2MSr8OBFeEK2cM f3vPGnhlGO/7as7lOUZALqMDqTbda0H8+nCNxJ11RgQwDQ2I6D/Q4QVBFu1OIOQ/niF8 0tC3HQuYL1StzIkGAvtUdiCJd8l1TSpoi+sw48DAxdGt5uNOneKhi1ew7QKoXoBKKA3s xvKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=J22GtAjA; 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=linux.dev Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k1si20503864ilo.14.2021.08.25.01.37.00; Wed, 25 Aug 2021 01:37:14 -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=@linux.dev header.s=key1 header.b=J22GtAjA; 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=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231765AbhHYIfe (ORCPT + 99 others); Wed, 25 Aug 2021 04:35:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229788AbhHYIfa (ORCPT ); Wed, 25 Aug 2021 04:35:30 -0400 Received: from out0.migadu.com (out0.migadu.com [IPv6:2001:41d0:2:267::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 229E4C061757 for ; Wed, 25 Aug 2021 01:34:45 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1629880482; 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; bh=nMKSuVzaG2Rrxo6b48p2rwBfxxJ2KT7SrwxgTpDKdz0=; b=J22GtAjAyUq+4ucuS9rnaXAJPz3AmlaomyblNnodTKKXjcUDkTQUDguILGqFq6bgkDPIza smdbouKnfcQw9F0inhuiY6JsfHFz73WhlkgWu4f4PlnxJxpDGCqDZqHVqEO9OUeD3GeNrj J6qiPsxHSJdpaU5r8E9VP8T3+oZikYw= From: Yajun Deng To: bhelgaas@google.com, arnd@arndb.de, robh@kernel.org, lorenzo.pieralisi@arm.com Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Yajun Deng Subject: [PATCH linux-next] PCI: Fix the order in unregister path Date: Wed, 25 Aug 2021 16:34:25 +0800 Message-Id: <20210825083425.32740-1-yajun.deng@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: yajun.deng@linux.dev Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org device_del() should be called first and then called put_device() in unregister path, becase if that the final reference count, the device will be cleaned up via device_release() above. So use device_unregister() instead. Fixes: 9885440b16b8 (PCI: Fix pci_host_bridge struct device release/free handling) Signed-off-by: Yajun Deng --- drivers/pci/probe.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 0ec5c792c27d..abd481a15a17 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -994,9 +994,7 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge) return 0; unregister: - put_device(&bridge->dev); - device_del(&bridge->dev); - + device_unregister(&bridge->dev); free: kfree(bus); return err; -- 2.32.0