From patchwork Tue Jun 23 19:55:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 191560 Delivered-To: patch@linaro.org Received: by 2002:a92:1f07:0:0:0:0:0 with SMTP id i7csp2308748ile; Tue, 23 Jun 2020 13:26:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzukzbkmIaIuV1bHj9vEoCZ6CiN2IG+dvSVguGIFigpivZM/ttkAnFE+r/Ga14nnR9ITZDI X-Received: by 2002:a17:906:c150:: with SMTP id dp16mr21291416ejc.536.1592944015258; Tue, 23 Jun 2020 13:26:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592944015; cv=none; d=google.com; s=arc-20160816; b=p3q4TDb1WIv8R4ycOPRfTwN4b5KFizeNCGZTzeSBd97idWuYI/kqm4OSxLy9pN/caT haStcXmF7VRUqvtjnh60r2X6LyDfMLtb2qDwW+1TBAjM8UVtEhEZEaCw169LxhihNCtk TQtKti2WziqRBrcwpp68FkltIPd2PdypVqDvOwR7Sy7V8kp6BBYnu0nmag4xoaNYdXp8 zpedBfjk2KUBKMlEfYkpmZbV9M0bkW4JYwzk2O4DN/DgAliAnqVyAeFqrdAqAFHEYtff UWYPOvQwa7KXi0xMVnnbFfZU8eb5ULrOxxbuZ7FfN/HkiGWgc+Y9zOhwDc5xh4JiWagz odAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yOj9Hfr8HKGfVrVbMHdk+rapiqPf7vwRkFEF+mkwvOw=; b=tcizLPZ12MmKT0pYr++wCIRRCOXf8kLjAdl5bCz5khIDQ/wRuptJdLKnI0cRx3JGXk OvtLgqFcOd/jnG/AHzHrY06HFrLkokmoX5EXeopYORyrWEsVaGmiPtO16EjpuqO0rfFM w4PBFhttfd2zRaT6wjRoKmtnUdqf65IEYtjBNH5oRvP+g1WuOp/Wvjy+10Z14QSHUQcJ 0Ef6nnLFIizhruvBUTLcrty8jjqF2qc1RN60IgoGjnlrJQbJ5H3spn08wAP/Wx2AVEVz 7A0Q/9mZxDcUlaOQaYo3fkLWHtgNFaSbwNiAYBwNBDLaE/34Mn0YGPGC06k+N/7MU+Bo YFHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qBoZtrgE; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e17si2073888ejk.740.2020.06.23.13.26.55; Tue, 23 Jun 2020 13:26:55 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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=@kernel.org header.s=default header.b=qBoZtrgE; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390717AbgFWU0x (ORCPT + 15 others); Tue, 23 Jun 2020 16:26:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:46172 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389512AbgFWU0w (ORCPT ); Tue, 23 Jun 2020 16:26:52 -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 B4683206C3; Tue, 23 Jun 2020 20:26:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592944012; bh=DV9HBnnggnuXJR8WVIySzNUQiSadqv442HEQBtx5BcU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qBoZtrgElz0yUOWQO8liXLMt+p8eV6Xjt5Ukee6Ml15kUi4MdsDKWKXPcMXyaq1Nm 3SFq1wuMmBXc3IbtFsmSxgNSUfoUquXjXKylQqyytfqvsQ4kbWFssH7EgB2VxYIyi9 auOUVwlf/wZnArjf0luc3CfKZYjd4LV9qDAcVfcU= 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 5.4 139/314] PCI: Fix pci_register_host_bridge() device_register() error handling Date: Tue, 23 Jun 2020 21:55:34 +0200 Message-Id: <20200623195345.491600428@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623195338.770401005@linuxfoundation.org> References: <20200623195338.770401005@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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(-) -- 2.25.1 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 83d909abc61d1..8fa13486f2f15 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -867,9 +867,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);