From patchwork Wed Sep 11 17:11:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riyan Dhiman X-Patchwork-Id: 13800928 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 35EF0EE57C6 for ; Wed, 11 Sep 2024 17:13:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=x6xlgjjvIv4Tu6d6E5+S2TBi3KJntXgaOfCvHBzY5Ik=; b=zjqH31DM2Bnvm5qkfIXY6BXWHD z9au8c98I337jaEGKtZM0XtcjiohoVRly3lo/dUCrEZlglOhzKOnOdHz1/rooXVzNL2jinS2S6+OH /JWcD85IwSGRZl/P57S4uGNxEE7bz0vvxzdUurWQAmu3ZClc/9q+pUmGLC0JLGG0lE6l2Gcv1l/0C S/sCCPDtjD/ADWXZUEZ0rldLAzBebZ4y9WOcGTkiiDBknyipYPHLKKKx7uXz7e4bfSZDshX0DbyuO DWIlaSANQjUFSaOD6DRxtcTFDv6Z3ao+ebTk0SUG8IcmqzlLhkgH/gT9HknXMyMYOPrgIH3WKx73V /ng5bCUQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1soQu9-0000000ASur-3UP8; Wed, 11 Sep 2024 17:13:21 +0000 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1soQt6-0000000ASir-0X55 for linux-arm-kernel@lists.infradead.org; Wed, 11 Sep 2024 17:12:17 +0000 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-7d50e7a3652so60949a12.3 for ; Wed, 11 Sep 2024 10:12:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726074734; x=1726679534; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=x6xlgjjvIv4Tu6d6E5+S2TBi3KJntXgaOfCvHBzY5Ik=; b=k1SNt8OhRrzRHR1Hjgu3Qj9gXf+t41kAQjomDdHKyXAM/LivrCkPIpwHWv8n9z4kRB tS3MwF00U4PCOhMv7Rcg6ZigxQQlcKdQTMRN6reyRiDwJNe8yzQZimvi350IE6BYOPCh z2BH8rYSDvSfs/ZPpnl3Nv+gNazMIQW+rMvRfaeATNNbwrSNXDzPx2EfbONLjb+7iOXt 7GzNxdVxYE1YcP/QpeWF/Jmg3HHfuxOaogbPaz/+uUubDe6gjHKCRDyTK097q+0MJUwA WMoCsppZqRNcP0Q9U8FS1cJtfZfbRAjuRHRYhaPuoG2OOcXpVCrYu32vUQuV+0KnHr43 zGog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726074734; x=1726679534; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=x6xlgjjvIv4Tu6d6E5+S2TBi3KJntXgaOfCvHBzY5Ik=; b=qtjWUTOXxPIsk1vaUJLCaXUMNLVUle+4wATv5pEdVd+lTjq0fHkqjJUG39fXI3tjpY oMuAHRqQRppWOWUO+k/HBhl2m1HBpyysHAsRFfWwbH8r5IK91gSevFAjRL1ERUYQ3IVp V0tk8HhM6k5QDGMaAH47w6w9Z8wbbRA+2Y0fz1uFkmaAMGd2u7NCWkfoKwwksFJ4qk1e aqdJwzltX50EoYhunTiCyfaiNFfEfCFiJhciR+n2siPcxZJi1sqa3XttmbA1u8MYHTBM SCDbiskEROjb/GvYUeB3evJobpiVVO3OKY6zb8+VpYqlo0eEZud/erWOMs8cXswiIyIP MrGg== X-Forwarded-Encrypted: i=1; AJvYcCXho4EycgVeg7M+gAgurP0pZFY9ld448m1HErTrDcm+ZL7pYgVF9ETewYoC/yRsc7mjZTEMXxBkfmxU7ScKgpGy@lists.infradead.org X-Gm-Message-State: AOJu0Yx6lKkyUnGRbnustrBDuDKPtfBolfZHrn4Ux03ZfWBYCT1LtHlb VI0xLTr9rmLFTSmygkFB6CbUoDXPkuy0zfjKWPrR8f0qlZBwgPYh X-Google-Smtp-Source: AGHT+IEd9DUYp7cewHHHvNv74waHQ4dQOFb6ONOUbfu4/MofpupHbJr5iv8/iTXTvi/uirT/M2eDAw== X-Received: by 2002:a05:6a21:e8f:b0:1cf:513f:f1cb with SMTP id adf61e73a8af0-1cf5e03398amr7177453637.4.1726074734275; Wed, 11 Sep 2024 10:12:14 -0700 (PDT) Received: from fedora.. ([106.219.162.154]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-719090c9b08sm3193102b3a.207.2024.09.11.10.12.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 10:12:13 -0700 (PDT) From: Riyan Dhiman To: vigneshr@ti.com, s-vadapalli@ti.com, lpieralisi@kernel.org, kw@linux.com, bhelgaas@google.com Cc: kishon@kernel.org, linux-omap@vger.kernel.org, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Riyan Dhiman Subject: [PATCH] PCI: dra7xx: Added error handling in probe function when devm_phy_get() fails Date: Wed, 11 Sep 2024 22:41:13 +0530 Message-ID: <20240911171112.46322-2-riyandhiman14@gmail.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240911_101216_188574_A7B043CE X-CRM114-Status: GOOD ( 13.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org While creation of device link, if devm_phy_get() function fails then it directly returns PTR_ERR without any cleanup of previous added device links. Added goto statement when devm_phy_get() fails, to handle the cleanup of already added device links. Fixes: 7a4db656a635 (PCI: dra7xx: Create functional dependency between PCIe and PHY) Signed-off-by: Riyan Dhiman --- drivers/pci/controller/dwc/pci-dra7xx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c b/drivers/pci/controller/dwc/pci-dra7xx.c index 4fe3b0cb72ec..c329d107b811 100644 --- a/drivers/pci/controller/dwc/pci-dra7xx.c +++ b/drivers/pci/controller/dwc/pci-dra7xx.c @@ -762,8 +762,10 @@ static int dra7xx_pcie_probe(struct platform_device *pdev) for (i = 0; i < phy_count; i++) { snprintf(name, sizeof(name), "pcie-phy%d", i); phy[i] = devm_phy_get(dev, name); - if (IS_ERR(phy[i])) - return PTR_ERR(phy[i]); + if (IS_ERR(phy[i])) { + ret = PTR_ERR(phy[i]); + goto err_link; + } link[i] = device_link_add(dev, &phy[i]->dev, DL_FLAG_STATELESS); if (!link[i]) {