From nobody Sun May 24 23:29:00 2026 Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) (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 ACD7C3DBD48 for ; Wed, 20 May 2026 14:45:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779288314; cv=none; b=a0qwmVZsrU/ugLiDzAU2iiZ+IqI+kKP5E37OmJzSOApRM78MUFbvOEsiztFFhi+WzXxIFn3JlfVubffDVirYhpidSXulDaZ2slGcAZ6FbYKOy6b8Q2q/PL99WJ2d6WRB2Yv8seQMdpBoa4dxU4SQ7m3s1f4BLn7c5lFIj5yQfTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779288314; c=relaxed/simple; bh=LQbm15rAKPz7MFzVtKlTkrfu5UxXb3siz4fc6NJeMKw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=qx8jOt6fk09SoMEDnvWVglL0PfOfNnhrKb/OWddruNINvLcIHV8JfIIviFIZxpU8qISL40nuQM3PItsWxfHxtLYsD8ZUQAihr1Q3ibeDiLpaPsfW7OVNK4Tko29jbDiDjy/e8ok/orfMLvo0+uaMMooDiqOfj5nEN8hJqwqK6lA= 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=K9Z48owy; arc=none smtp.client-ip=209.85.215.176 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="K9Z48owy" Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-c6dd5b01e14so2287793a12.0 for ; Wed, 20 May 2026 07:45:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779288312; x=1779893112; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=4ks/pYuySM/VySSLZBKDsm+9ZYqarxYGQ3/xDReTI44=; b=K9Z48owyfYODDYJmis4V9B2k8DR8qJA5WhyuTWzltjseDojOeZImaKAJsyYO5tSqge QuolCTB8+IBzkYrGufLZRK6zRV/aWvSv7AKTsoYe4fmzsOYvIZJfqcUHLTJ/9v8Kqevb rAd/8hscf8IhS5z5WhoNc0yOhu3ZiUsSxcaJERPLnrE8BEcjhZ8bHw+dT8PxhcTim3gh k8LnLwkVwn6jDPTvxpbr0h6j+hNQQ42RLGoCDR0mBONVVV/H0UEHGvcJ3yzYRRwu2WFO XXb47fuGZun534OKGMEpgxLfujnIwbYSJPCcb7zu4jjkE1dLYfvyGKEYJs9AidigaGJT 14wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779288312; x=1779893112; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=4ks/pYuySM/VySSLZBKDsm+9ZYqarxYGQ3/xDReTI44=; b=nClHLiTkjlvgM0XRzug+ftXmsZkB5TDXwoRDa0xmUL1SGHtf9D7fAF5+EnNhvHcanZ 59uS29R+fLQO9tCOXJjVkaXhajZBuDMGxdCY9hIYzCoMGsVBu0E5C+I7BFxjdsdmrCDJ 38nr+bd40qq3bX1xBlyEKw3PaQlo38bACvUFlDgoeuK5XJToj9gRIwG1MHHMTvMssW70 4q9K+h2xUdt4IhGze7r7LgeTSLNxKqVBZZUgFMjE2GGtIuRW/eU3ocsCn2hlD70Pv+Xx FUEdMWSUNf/qtOdRB8Hulo1duQjRiJ3icxlCJr4ardgzI6U9/+zDwo0oUpvvIkUsKJTf X6TQ== X-Forwarded-Encrypted: i=1; AFNElJ+YWOCjlsQ077XDsWrm9VhFUQUfF0LIyTVl3pq4Ix22RUX8/wzF0NvnJlCrfmmA3CXMCr4yGD1aIsL8TIQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yx766y425NerpP9LHrR26Q3a0Nru4G6BbhIfG2DrU6L/ko4ye2L FqCnNrI6wvw8eeGfl3kO4hX+dp0IraLgz2dc/diJzLu7CLuwLSmygYrS X-Gm-Gg: Acq92OGOUqLIETmLbY88SMGDcQTJE7M1LRu4xXRnZs/AKj9G3syZjsZ4F2Gz3nHgpR0 TUMEpMidDUrz8IHnj9Y5qcYtK3tZrLFRQ6DCO36qDvLaVdB+KxTFls4o3GfK2DPspq4v1JtZGE7 qpxdCV8XyPsrfrefZRby8ulie8ov4vlHyYdHpttwUSX7UzpZuL0E99XEB972foaw5+UBmgIJGC0 A1pm3Pis345IqiGMbjqnUmMa+/0oBtiMeKRP7iianItJKvZvK80HlgCFZ5cOeJ0Q+VX1PgNSb3B fAcTv7r0ZB32xi0M9Xb69yE1DSp1og8sSVLxRvaZs/p2eGoZNViiU0/x6rabcrU9SdfImsUIeko +hf3DCUUTimA7GM3Ld4EUMJJ87dZrOlXQlQwbbP3qsbp1QckVpfWkYqCd2I3f9hP05Lqquw9LO+ QnG5DEl+QTnDiLPbEhvo+WSC/20gb+AFuYOxPA+K9AAVHOQa69v1KEtImv1kZiEs/gmTFiPqEd5 ztgqj1nSpskeE9URPiIrG1+ORXb X-Received: by 2002:a05:6a20:7d9d:b0:3aa:f9cb:d438 with SMTP id adf61e73a8af0-3b22e73d2dfmr26321921637.21.1779288311345; Wed, 20 May 2026 07:45:11 -0700 (PDT) Received: from junjungu-PC.localdomain ([223.166.246.30]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c82bb114a70sm25363425a12.22.2026.05.20.07.45.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2026 07:45:11 -0700 (PDT) From: Felix Gu Date: Wed, 20 May 2026 22:45:04 +0800 Subject: [PATCH v2] PCI: eswin: Fix resource leak on dw_pcie_host_init() failure Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260520-eswin-v2-1-a221438a6317@gmail.com> X-B4-Tracking: v=1; b=H4sIAO/IDWoC/0WMQQ6CMBAAv0L2bA3btGA9+Q/jYakLrBFKWkQTw t8FNfE4yczMkDgKJzhmM0SeJEnoV9C7DHxLfcNKriuDznWRW3SK01N65VxJh5ow18bC6g6Ra3l 9PufLl9OjurEft3gz6hg6NbaR6f8zWPx+EypUZJzDUtvKejo1Hcl970MHy/IGyVVDB6YAAAA= X-Change-ID: 20260519-eswin-997a8fa10245 To: Senchuan Zhang , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Manivannan Sadhasivam , Rob Herring , Bjorn Helgaas , Philipp Zabel , Yu Ning , Yanghui Ou Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Felix Gu X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1779288307; l=2320; i=ustc.gu@gmail.com; h=from:subject:message-id; bh=LQbm15rAKPz7MFzVtKlTkrfu5UxXb3siz4fc6NJeMKw=; b=G+RkdFqcfTqcBFzkTQhVlviALLkW5j91oDSyOVkEcniSwp5sA7l+GmlLKRPddRKQFNitxEE2F Q2eTVm6CNt1CBBo3us49NdOYq4zE8A6T6HvmrXjpt/axkSqJxOLPjXE X-Developer-Key: i=ustc.gu@gmail.com; a=ed25519; pk=fjUXwmjchVN7Ja6KGP55IXOzFeCl9edaHoQIEUA+/hw= When dw_pcie_host_init() fails, the code jumps to err_init which only calls pm_runtime_put() but skips the cleanup of port resources allocated by eswin_pcie_parse_ports(). Additionally, the incorrect port cleanup code in eswin_pcie_host_init() error path is removed since port resources should be released in probe's error handler, not in host_init. Fixes: b593c26d081a ("PCI: eswin: Add ESWIN PCIe Root Complex driver") Signed-off-by: Felix Gu --- Changes in v2: - Fix Mani's comment. - Remove incorrect port cleanup code in eswin_pcie_host_init() error pat= h. - Link to v1: https://lore.kernel.org/lkml/20260416-eswin-v1-1-a4991725b= 5ca@gmail.com/ --- drivers/pci/controller/dwc/pcie-eswin.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-eswin.c b/drivers/pci/controll= er/dwc/pcie-eswin.c index ce8d64f8a395..7a02ab91a190 100644 --- a/drivers/pci/controller/dwc/pcie-eswin.c +++ b/drivers/pci/controller/dwc/pcie-eswin.c @@ -182,7 +182,7 @@ static int eswin_pcie_host_init(struct dw_pcie_rp *pp) { struct dw_pcie *pci =3D to_dw_pcie_from_pp(pp); struct eswin_pcie *pcie =3D to_eswin_pcie(pci); - struct eswin_pcie_port *port, *tmp; + struct eswin_pcie_port *port; u32 val; int ret; =20 @@ -252,10 +252,6 @@ static int eswin_pcie_host_init(struct dw_pcie_rp *pp) reset_control_bulk_assert(ESWIN_NUM_RSTS, pcie->resets); err_deassert: clk_bulk_disable_unprepare(pcie->num_clks, pcie->clks); - list_for_each_entry_safe(port, tmp, &pcie->ports, list) { - reset_control_put(port->perst); - list_del(&port->list); - } =20 return ret; } @@ -347,18 +343,17 @@ static int eswin_pcie_probe(struct platform_device *p= dev) ret =3D dw_pcie_host_init(&pci->pp); if (ret) { dev_err(dev, "Failed to init host\n"); - goto err_init; + goto err_pm_runtime_put; } =20 return 0; =20 err_pm_runtime_put: + pm_runtime_put(dev); list_for_each_entry_safe(port, tmp, &pcie->ports, list) { reset_control_put(port->perst); list_del(&port->list); } -err_init: - pm_runtime_put(dev); =20 return ret; } --- base-commit: e98d21c170b01ddef366f023bbfcf6b31509fa83 change-id: 20260519-eswin-997a8fa10245 Best regards, -- =20 Felix Gu