From nobody Mon Sep 28 06:35:37 2026 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 79F3033AD8C for ; Tue, 25 Aug 2026 14:15:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787667348; cv=none; b=lWSm/+JFzyhjNq1YoZuBwJ+wKbLijBRXp3RhR3GCSPPyb3PkY+Jn8qrxl/wVUCg9AZgPQwHiHAKZ0lE/UDf9iUxwIuG6inqQXoKy/bSSv7uuflbhpFvMq+UP8edHKAsWcwWSjazvPvur8LOg7dV0YbFJ6u10hj5WAc4z6dq8x2o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787667348; c=relaxed/simple; bh=N8dfMV2RTxCE7arhbl2EaVyOwVpkyAhCuc/xfSBqTcA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=dRBY8S3v/9o3HkwhOv4bJb76wo0PThRDZLRsG0JDDOdD+66VmmPR9aGr1Yd1vhQiYMtAWCXqQrPDTwg5twj+rhDCDGnc11OsmRRvaBEyubF3Gkrc4QjehLbxvNBBYLr0lf5WpH5vmUvKzYaG/fWfKyMaBfFUnq9beKQYOoYLlvM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Rk6BRX9b; arc=none smtp.client-ip=209.85.210.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Rk6BRX9b" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-8518b3ff3e9so4097901b3a.2 for ; Tue, 25 Aug 2026 07:15:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787667347; x=1788272147; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=wGI8avUDsdCwdcQZ5iPHHrLahXfIYCIB9Ws1YZ5JElk=; b=Rk6BRX9bSC7P8j2tsSdB4hGDOyFdfqUti7h+0lq2rqiz8fWK9iS5DptYelTguEXn5e Pe4fNYi2COyl1VpyhMx5OYFuGqx0O3UErJ7TqEWsV7v0E+w0p6y5hZVzfgrYz4ybmdtJ TXZ508d/62gg6myXfA4sIpL3j3hsOgTWBNVmYZguNrEpcNJNKC+cQ0vGTAEgjffogb4E dzvUYO3s5YaIeDwthv/2sFETkUrdQCjZaujfPnJSzsbkUSzu8moL4uYhnVxnDVAsDJbC Or9qYKWmSntcptXYnppLvijY5ZYL9bCC24uFdDgiwVd0MjBBHhX6LgYLjyc1LXttb9Jd maWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787667347; x=1788272147; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=wGI8avUDsdCwdcQZ5iPHHrLahXfIYCIB9Ws1YZ5JElk=; b=Nrw8hshIszJAZ4q/2aK3W4337NJqSzfVk/ZS0MLyE82BkGMbVxMmozrg2tR92XHV7L 3UQUDoJfNWNBatdC6K3X2y5DebqcJ6D8OOq3Ua6UYD2av08jPfsuze/VlTnnoxW0LCtG xschkSGkFBaIc+DNwiPMq0zh/0HxysCgfXftORxL4dDhhzWNP8RhKocUZh2gK1RY42aT gpHBcIyomTSkh3OtGEd9leMJo6sErNfaFp+SDgQCiLVDEXI5T/LMGQr1trho5tiUNO7o 6KX9aVwsGTy09a9ZUv6TjjgFflSejc40KnOzymgLazL86u72G+tSA7NEB4Xg5wszjBi6 3dwg== X-Forwarded-Encrypted: i=1; AHgh+Rr4qvFw0mFrxpvVwSfwqXGDvjTbDbHslAi9oSMBDduwtx6OC74ldJxW0jz7YXkgO9TAePYS7jl9iFNKuN0=@vger.kernel.org X-Gm-Message-State: AFuF++mjOMUNuSjGSY3RY3pZYjEXF4p/ZB/kd/gaDGvHkag1uarypOeB 4VBHi1nHmj0Mf91f/1bXRBKq+ylheQS0K5G8kfyi4RrDayZH1wYDtY+lK19Dglsk/f8= X-Gm-Gg: AR+sD12pRV3lZI5yFyyI+otiokYs048hpcmLNJKIcsONpzbzZS5zrxFCUAsTfuCmFaj AnQDT2BFyXgxp6ko/sKy7Uxa6N/LR7nxPBV7FOJlxcoeTy6i4vhW2RZWCDVbrMW+8MaCkZJs/41 f2eWX9gBKUP7bC7Rp0kTBFnO3gJUe9BV4Z5/TxDEr/DeLDWWi19DNFEQSOEctOkPdnvk/44PoCi jiWlfoAmyuVGzhXbHxUtXyoJ6Q+I4ltocGei0NX0SzjZ3Mj8xRXDcq4jHr4aqDeGwTjT1vP67mt aoLQ1QyE97xMFcoYBuPF3Gavkpscb1JWq8tHM/BaNpSgI2oLackcT4aCl+F9jheacol2GvHL2Nm zzol9rArymQJnSYShOmCab7dBTD8nMxhsqDrzQ+orSeTas91uY7i4EXOlWAPcXhQonUIfKlIUZo n1qZOaq5j7add9F7rCuxiL8Fshz47V6xNnST1ruAOTLbhv8/59aqJcw95ayMliIgpaBNg8IJpzL F1OVroE7U6B9Ls66xiSX4cxfSprTiuVAJBv64UQFokqKeJ1bW7w X-Received: by 2002:a05:6a00:928f:b0:851:ba04:ca02 with SMTP id d2e1a72fcca58-851fa070bf3mr58592115b3a.16.1787667346530; Tue, 25 Aug 2026 07:15:46 -0700 (PDT) Received: from hanzj-mi.. (ec2-99-79-140-187.ca-central-1.compute.amazonaws.com. [99.79.140.187]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8520eed5034sm3122767b3a.1.2026.08.25.07.15.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2026 07:15:45 -0700 (PDT) From: Zhijian Han To: Richard Zhu , Lucas Stach , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Manivannan Sadhasivam , Bjorn Helgaas , Frank Li , Sascha Hauer Cc: Rob Herring , Pengutronix Kernel Team , Fabio Estevam , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev, linux-kernel@vger.kernel.org, sashiko-bot@kernel.org, Zhijian Han , stable@vger.kernel.org Subject: [PATCH v3] PCI: imx6: fix endpoint init error handling Date: Tue, 25 Aug 2026 22:15:26 +0800 Message-ID: <20260825141526.3911472-1-hanzhijian1991@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" imx_add_pcie_ep() ignores the return value of imx_pcie_host_init(), so a failure to enable the clocks, regulators, or PHY during endpoint initialization goes unnoticed and the driver proceeds to initialize the endpoint against unpowered hardware. It also returns directly without releasing the host resources when dw_pcie_ep_init() or dw_pcie_ep_init_registers() fails, leaking the clocks, regulators, and PHY that imx_pcie_host_init() acquired. Check the return value of imx_pcie_host_init() and register imx_pcie_host_exit() with devm_add_action_or_reset() so the host resources are released through the devres framework, which unregisters the EPC device before powering the hardware off. This mirrors the root port path, where dw_pcie_host_init() releases these resources through the same framework. Reported-by: sashiko-bot@kernel.org Link: https://lore.kernel.org/all/20260824152857.DB9771F00A3D@smtp.kernel.o= rg/ Fixes: 75c2f26da03f ("PCI: imx6: Add i.MX PCIe EP mode support") Cc: stable@vger.kernel.org Signed-off-by: Zhijian Han --- v3: - Add Fixes: and Cc: stable tags v2: - Use devm_add_action_or_reset() for imx_pcie_host_exit() instead of calling it directly on the error paths, so the EPC device is unregistered before the hardware is powered off drivers/pci/controller/dwc/pci-imx6.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller= /dwc/pci-imx6.c index 39790e66b..f0fb4e1b0 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -1488,6 +1488,11 @@ static void imx_pcie_host_exit(struct dw_pcie_rp *pp) regulator_disable(imx_pcie->vpcie); } =20 +static void imx_pcie_host_exit_action(void *data) +{ + imx_pcie_host_exit(data); +} + static void imx_pcie_host_post_init(struct dw_pcie_rp *pp) { struct dw_pcie *pci =3D to_dw_pcie_from_pp(pp); @@ -1634,7 +1639,20 @@ static int imx_add_pcie_ep(struct imx_pcie *imx_pcie, struct dw_pcie_rp *pp =3D &pci->pp; struct device *dev =3D pci->dev; =20 - imx_pcie_host_init(pp); + ret =3D imx_pcie_host_init(pp); + if (ret) + return ret; + + /* + * Tear the host resources down via a devm action so that, on probe + * failure, the EPC device created by dw_pcie_ep_init() is + * unregistered (also via devres) before the clocks, regulators and + * PHY are switched off. + */ + ret =3D devm_add_action_or_reset(dev, imx_pcie_host_exit_action, pp); + if (ret) + return ret; + ep =3D &pci->ep; ep->ops =3D &pcie_ep_ops;