Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3483507imu; Sun, 11 Nov 2018 16:08:01 -0800 (PST) X-Google-Smtp-Source: AJdET5d43VMriPWNu5uQD/Vnkae8tmosanXt5cjymew1oytE2qE0kVAiKSaTt+RCL4eY3p+SdkZN X-Received: by 2002:a65:4946:: with SMTP id q6mr8325574pgs.201.1541981281426; Sun, 11 Nov 2018 16:08:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541981281; cv=none; d=google.com; s=arc-20160816; b=KiFgmk5XmRSL/YYy8A++opu4m3KNbHASWZ+AieOXDEm7grJti3z3AtMr05l2kPBW10 RhNLxnQ5iGTCkIlh28aE8dvi/WQ6gEwimZAthTiZIwR+0pcVInTx8iroAil2qq+i5PRP KCbNCSns/h3fJLPrSf6WSYHbh7qDqSuxLi7omV48v+vhCN8MNKwAo0NxSOn/xx6Qh7Lo iZNnkwnxWZyjVltLYLcYgpQEpohrEhZs2IAIL/WgIn+CKNMdUcgJ0kNamsZib16W8azX Tm8ALIwIr/tDEGQVOXXEvs2XWmY+EmB0d+GcHx5HLvcP2j/PZlc3MsvVLXXn6Kub0Hr+ Emvg== 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=9EPkBEWMq8FP1Gbi9ZPqgFuSgwQ3GGIZB+ywiO5M/sI=; b=tMZc97iYL1WcDhQMP/DMKuXDrOur5SB6q3tYIRAJmqCgM5gsBB33YOws76a5B8hibf prRXmhiwrYgT3zm1l5VRWofGStSnXB2talx0/oef3R63rpUWJpOpKekG/rC4G84kBKAx M8syFsEk92QfALbuDZMIZ6MOJm9z8XYoUcpFoEI9tkvYWGGGILFqjdz/33csIIjOqUkP Ig+uP6XxL0KzEjM4XcLgtTfZ3NcOQlhk2Vpya6JgFx2ANLncTS3HAE0k91C+iH/1D2Mi Qisa1dxr92T0nwPjC8j2ZECKutXRBn1P7zsHC33dxOlZDbFMEDarUdAkuTZfE20DmG1o lyYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hRqFk1Kz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6si13616220pgk.201.2018.11.11.16.07.46; Sun, 11 Nov 2018 16:08:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hRqFk1Kz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732246AbeKLJzx (ORCPT + 99 others); Mon, 12 Nov 2018 04:55:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:34412 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731933AbeKLIRo (ORCPT ); Mon, 12 Nov 2018 03:17:44 -0500 Received: from localhost (unknown [206.108.79.134]) (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 4375821731; Sun, 11 Nov 2018 22:27:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975268; bh=ipmYIZzd8QlDFq7L9Y2sb/esF+eDHJwp7P/GCiP2FGc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hRqFk1Kzmq5Fs0g0OmPGEOsLeXaRii8i0NnGChNB+08tHIQcVD+XrgCfR+gCaxj6J ZGEPAcQP0ZygxI3Hy2NlRIcZM9AybUMY7uEPZQ4A8yxt9BB4Tc8zktdRXSmD5IBURa EBMVyUwkF+63Z9CLJHVIYAluhNgIrMwohFhtkB60= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin King , Alan Douglas , Lorenzo Pieralisi , Sasha Levin Subject: [PATCH 4.19 163/361] PCI: cadence: Correct probe behaviour when failing to get PHY Date: Sun, 11 Nov 2018 14:18:30 -0800 Message-Id: <20181111221643.285987365@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alan Douglas [ Upstream commit aa77e55d48124d0d78456eabf872fffb5decdbe1 ] Test the correct value to see whether the PHY get failed. Use devm_phy_get() instead of devm_phy_optional_get(), since it is only called if phy name is given in devicetree and so should exist. If failure when getting or linking PHY, put any PHYs which were already got and unlink them. Fixes: dfb80534692ddc5b ("PCI: cadence: Add generic PHY support to host and EP drivers") Reported-by: Colin King Signed-off-by: Alan Douglas Signed-off-by: Lorenzo Pieralisi Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/pci/controller/pcie-cadence.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) --- a/drivers/pci/controller/pcie-cadence.c +++ b/drivers/pci/controller/pcie-cadence.c @@ -190,14 +190,16 @@ int cdns_pcie_init_phy(struct device *de for (i = 0; i < phy_count; i++) { of_property_read_string_index(np, "phy-names", i, &name); - phy[i] = devm_phy_optional_get(dev, name); - if (IS_ERR(phy)) - return PTR_ERR(phy); - + phy[i] = devm_phy_get(dev, name); + if (IS_ERR(phy[i])) { + ret = PTR_ERR(phy[i]); + goto err_phy; + } link[i] = device_link_add(dev, &phy[i]->dev, DL_FLAG_STATELESS); if (!link[i]) { + devm_phy_put(dev, phy[i]); ret = -EINVAL; - goto err_link; + goto err_phy; } } @@ -207,13 +209,15 @@ int cdns_pcie_init_phy(struct device *de ret = cdns_pcie_enable_phy(pcie); if (ret) - goto err_link; + goto err_phy; return 0; -err_link: - while (--i >= 0) +err_phy: + while (--i >= 0) { device_link_del(link[i]); + devm_phy_put(dev, phy[i]); + } return ret; }