From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7933DC433E0 for ; Tue, 23 Jun 2020 20:54:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4915720724 for ; Tue, 23 Jun 2020 20:54:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592945683; bh=M8WePFkO2RB60+1w99NmjnzDngSvR9I6iLpfPoEiAko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=rnu+fvl40mYgFZw++g0dWVXB+tzmYKNynA4zltfbwKmLFUTQLCNaAYQwQuVh1MIxY rgHeFXlMqMz8JUP34scq9UOjHoS5HUckCuyutOm9RN0bsSJcdna0AEaGAwzwuArw0f F3ZIg6wIAPUiEZRq1aI87GhKhB3naPKIZMD2tJEM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392991AbgFWUyl (ORCPT ); Tue, 23 Jun 2020 16:54:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:43284 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392394AbgFWUpl (ORCPT ); Tue, 23 Jun 2020 16:45:41 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4A17520781; Tue, 23 Jun 2020 20:45:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592945141; bh=M8WePFkO2RB60+1w99NmjnzDngSvR9I6iLpfPoEiAko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xA2vAMw+UBtnPzdsmfjTbTTXMFN/ImqDL4cSl8f+TF5KUJVdj2g5VTFlYubxNz6B/ 975G9Tvxg2+VL9kzamYAehcpk7ezjbwlFHE1ad/VAL0HOfJVROJqjAucEV8G38hKyx ddBF2p2ILog8y3u3S+zCt9meAyfblQMtQaGhw+N8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Arnd Bergmann , Sasha Levin Subject: [PATCH 4.14 055/136] PCI: Fix pci_register_host_bridge() device_register() error handling Date: Tue, 23 Jun 2020 21:58:31 +0200 Message-Id: <20200623195306.443001606@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623195303.601828702@linuxfoundation.org> References: <20200623195303.601828702@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rob Herring [ Upstream commit 1b54ae8327a4d630111c8d88ba7906483ec6010b ] If device_register() has an error, we should bail out of pci_register_host_bridge() rather than continuing on. Fixes: 37d6a0a6f470 ("PCI: Add pci_register_host_bridge() interface") Link: https://lore.kernel.org/r/20200513223859.11295-1-robh@kernel.org Signed-off-by: Rob Herring Signed-off-by: Bjorn Helgaas Reviewed-by: Lorenzo Pieralisi Reviewed-by: Arnd Bergmann Signed-off-by: Sasha Levin --- drivers/pci/probe.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 31cc04aeaaaab..55ece07e584a0 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -792,9 +792,10 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge) goto free; err = device_register(&bridge->dev); - if (err) + if (err) { put_device(&bridge->dev); - + goto free; + } bus->bridge = get_device(&bridge->dev); device_enable_async_suspend(bus->bridge); pci_set_bus_of_node(bus); -- 2.25.1