Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3654172pxb; Mon, 24 Jan 2022 14:32:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJxcGNI1u0EiWPBnlDR0TdYs5zUnR6Mco1MgnP5TjpkkeO9HQ72TAeJuLOpZjNEbipEizWFZ X-Received: by 2002:a17:902:b607:b0:14a:cae5:d8f with SMTP id b7-20020a170902b60700b0014acae50d8fmr15624735pls.131.1643063532842; Mon, 24 Jan 2022 14:32:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643063532; cv=none; d=google.com; s=arc-20160816; b=tBbbfK/FxbGugQ/B88Z7mBvZo3OHBcNAedLUSFcqBZCfQA7xRdUom+b4c83Qiva3vX HZxKe7mTIEK8XMPIhxjH0SZzeV1wWHR7rFMiJR0wDWfMFIgwr8g72s1VdEQzTVrfO+22 TDlrhrRp0ooWA7sPaJqxy2AmEf1rJmoRZix54oasp6YqWKKsVJpek5kj1CQhJRaLQm4g SjKIjg+wWo/MwHykh89qIOgDIDO0xGatEzLzAOCt76fju59XtTE05I1BZvEKPbIpRdWk BswAAmzGZp4MqM0TiCYuqLcAbkhAnYrRClCk77pz0zrf5pJHkHdMJ5ZNvR9qQseR+m23 bzHQ== 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=nXGe6wr/UeJXtn3pwGSZlBRRYQcGHPpYavq9RYESoUY=; b=KysLzO1AuslxUQYoRIHY2u57M7eAUxoFgwT9QV5TnH6tUI7ci2OUh4B42Tgb3YT09R LawonyTFkINQD+yHzPgCjzgYrG5L+fzDJVZNVstNybuUc1t5sb8p/HRmY2Wg6WkNqgZR IPn4STiZsMyXlxHHbHQa4s7cIHKGAXSmgBcnzyxmMkrUIcJbJOyCySXuhbUbkIGpf2th Vy7gYkKNputpaAyaisUr2GC8nI0KkP3EWLlUn5sgrXD0DVF9y2JyCC+6GaiLhjXdYSKa 2w+z6HHbJtyECvs1KR54nbPzgpK4NDj9wMtVaqq73ugqD1HMfdb7Wh6JKfHZgTbyLAcp qLnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2Jq46nqN; 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 e7si4238154plh.419.2022.01.24.14.32.00; Mon, 24 Jan 2022 14:32:12 -0800 (PST) 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=2Jq46nqN; 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 S1587041AbiAXW1j (ORCPT + 99 others); Mon, 24 Jan 2022 17:27:39 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:51444 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1454311AbiAXVcN (ORCPT ); Mon, 24 Jan 2022 16:32:13 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0C70B614F3; Mon, 24 Jan 2022 21:32:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4479C340E4; Mon, 24 Jan 2022 21:32:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643059932; bh=2hF7BRGsfHYFsaSCRg8aq1TO5nuw7n7HAXgR4OfbIJo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2Jq46nqN8oFpfSpVXfRX+s7uUVyEd9MnQ5aq7rsyezgei3CeP19hQ7vQSg5k6qblc +R9miQW+4yLNyOmMIdOYzUp6uLuzoyvmB2S1+4OkJXU3uIfwLguk61KB85fsHUbVN+ RaX+85UgSTdICtPQkhVCPiij3Da2/AS7CXtA00y4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Lorenzo Pieralisi , Stephen Boyd , Sasha Levin Subject: [PATCH 5.16 0783/1039] PCI: qcom: Fix an error handling path in qcom_pcie_probe() Date: Mon, 24 Jan 2022 19:42:52 +0100 Message-Id: <20220124184151.607878649@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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: Christophe JAILLET [ Upstream commit 4e0e90539bb0e6c0ca3768c642df9eed2118a8bb ] If 'of_device_get_match_data()' fails, previous 'pm_runtime_get_sync()/ pm_runtime_enable()' should be undone. To fix it, the easiest is to move this block of code before the memory allocations and the pm_runtime_xxx calls. Link: https://lore.kernel.org/r/4d03c636193f64907c8dacb17fa71ed05fd5f60c.1636220582.git.christophe.jaillet@wanadoo.fr Fixes: b89ff410253d ("PCI: qcom: Replace ops with struct pcie_cfg in pcie match data") Signed-off-by: Christophe JAILLET Signed-off-by: Lorenzo Pieralisi Reviewed-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/pci/controller/dwc/pcie-qcom.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c index 1c3d1116bb60c..baae67f71ba82 100644 --- a/drivers/pci/controller/dwc/pcie-qcom.c +++ b/drivers/pci/controller/dwc/pcie-qcom.c @@ -1534,6 +1534,12 @@ static int qcom_pcie_probe(struct platform_device *pdev) const struct qcom_pcie_cfg *pcie_cfg; int ret; + pcie_cfg = of_device_get_match_data(dev); + if (!pcie_cfg || !pcie_cfg->ops) { + dev_err(dev, "Invalid platform data\n"); + return -EINVAL; + } + pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); if (!pcie) return -ENOMEM; @@ -1553,12 +1559,6 @@ static int qcom_pcie_probe(struct platform_device *pdev) pcie->pci = pci; - pcie_cfg = of_device_get_match_data(dev); - if (!pcie_cfg || !pcie_cfg->ops) { - dev_err(dev, "Invalid platform data\n"); - return -EINVAL; - } - pcie->ops = pcie_cfg->ops; pcie->pipe_clk_need_muxing = pcie_cfg->pipe_clk_need_muxing; -- 2.34.1