Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp170420imd; Wed, 31 Oct 2018 16:44:27 -0700 (PDT) X-Google-Smtp-Source: AJdET5cR+8GbWfcImSrKihrytBC1VXVQbaZZHNKboCO1PYs67vdkvTSR3bBgDSVeFklYYIRZr4WN X-Received: by 2002:a17:902:7847:: with SMTP id e7-v6mr5419357pln.104.1541029467328; Wed, 31 Oct 2018 16:44:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541029467; cv=none; d=google.com; s=arc-20160816; b=cPSRDdtwlc83xrHFlp38quikmSNQa/l4u7QJksJ0aYxemX4s8LWoQ4zcxR/rVhhltd LlD2BFYY1JMIa1slZZ1kVHn5qLiuB/4WbdqM7R96qjG2qyA58fdY4eaVOiZmvMLyA2k3 YvRMPTq1Ux7vPFReb5moBYcjFEtiAxnBrU73l3Vck9W5Cl/jfos4L7TRsxHmb10NRShM KwJLVM2sj/H/VUYDcOLiaU+h0FIhRUF1i+a8RJafmnGEG57oyOPN2lxxYizwjskdEU0a Th3Se5Kj4+JlQEu0ECKypPlBI+UdQy+HPeQcOqvKAKBRMlTpOvxM/7d4xpUEBHw+eMmA YfJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=QQY0keoSG782Nvh7nbJ4SdeYMGVtYfPUJPM1YSm3wtk=; b=g54B9cXwPmQazGakMBaofXMAzHxUDe1fIBaEykwyKgirbzWk/uJL7y2LlVqSbi85Zn uutRwro0DUCW+acafleeZxWsuEGL6sQMm1+KPSWPW7SFMqlA5jL17SZq0AfiewRUGKCd 57qTp1QdC0davR5WDa0k9hAGUbSWrs3irluDxIDzLyTvr7QcIhDAO2Ypiqj3vecCGkRw wlPX4xn23o3nsCV7IMw53AncIghNFPmUNrr1zEfz6+WuyFMOavIWJjPQs6Iudzjj8FT8 Zh5Fgejo4l8ghFtBsM1CgTVJxoxy5CPHeCoxshxuWVYz/E0Yj7SGVF1yOPmy/Gl0RCIe kmUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=C5HZppsi; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m17-v6si30143928pgj.155.2018.10.31.16.44.12; Wed, 31 Oct 2018 16:44:27 -0700 (PDT) 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=C5HZppsi; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729292AbeKAIoP (ORCPT + 99 others); Thu, 1 Nov 2018 04:44:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:55632 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729048AbeKAIHk (ORCPT ); Thu, 1 Nov 2018 04:07:40 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 085CA2081B; Wed, 31 Oct 2018 23:07:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027249; bh=BUO7P0P+xdR7VJn0JH/KCflHbLnrDHUs2MdKga7UoHw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C5HZppsiScH+DqDRUyiHlGG5COnCXe/pncEQq38zJHyrjikELHbxw9AHunTxKBt+Y 1EbuVhwqYfzfQiLmpHbwhPvMEmwHcevZJNrypGyg7mNrv48/tsEcC3grnlrJmuZJWI jZNjAGa5+LFHO92ong8x2xSWpq+I6h6S92ZrzKuQ= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Alan Douglas , Lorenzo Pieralisi , Sasha Levin Subject: [PATCH AUTOSEL 4.19 119/146] PCI: cadence: Correct probe behaviour when failing to get PHY Date: Wed, 31 Oct 2018 19:05:14 -0400 Message-Id: <20181031230541.28822-119-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/pci/controller/pcie-cadence.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/pci/controller/pcie-cadence.c b/drivers/pci/controller/pcie-cadence.c index 975bcdd6b5c0..cd795f6fc1e2 100644 --- 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 *dev, struct cdns_pcie *pcie) 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 *dev, struct cdns_pcie *pcie) 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; } -- 2.17.1