From nobody Fri Apr 3 09:50:21 2026 Received: from cstnet.cn (smtp81.cstnet.cn [159.226.251.81]) (using TLSv1.2 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C538D2868B5 for ; Thu, 19 Feb 2026 16:48:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.226.251.81 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771519715; cv=none; b=mRUIwPuRFLAaJZ47tZQkegsjwBG1z60ObeK7EKU1LaIxrgS6w5Qfsm94HqXCMPzDovMiL2tFIY5vL18gkETau8wt7MemQigk/HdmUO+q3a8hr5RmkiJf30ssDCv79F7Xh8nNHiuSGj2458VQEFQTNIEkAhPaOmRbi3Bq2KKGU2w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771519715; c=relaxed/simple; bh=9/oDfC4WcIzAeBnF1PoizaIIu7DaBoNC5qHO8KmWWrE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Mkob7uqYr8Vn2cyYtGWi7nqSEjHWy1lOsCL2xLr7Rq/ZnaQ6AuQ7HYu2TpHQqSb9Hn3MfSyTMfQ2R2WfDYctqrZ8HlKxVVtbdYsWS1xsKM019aBKQrVPWndbAcUpF72PBVqlNvJYhA3Ul2DCAC+zWxbypj+lEm4bs9sVaR7x08k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn; spf=pass smtp.mailfrom=iscas.ac.cn; arc=none smtp.client-ip=159.226.251.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iscas.ac.cn Received: from DESKTOP-L0HPE2S.localdomain (unknown [111.225.242.233]) by APP-03 (Coremail) with SMTP id rQCowABXcdhwPZdprW_cCA--.1041S2; Fri, 20 Feb 2026 00:42:24 +0800 (CST) From: Haotian Zhang To: olteanv@gmail.com, vkoul@kernel.org, kishon@kernel.org, andriy.shevchenko@linux.intel.com Cc: linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Haotian Zhang Subject: [PATCH v2] phy: hisilicon: hi3670: Fix OF node and device reference leaks Date: Fri, 20 Feb 2026 00:38:43 +0800 Message-ID: <20260219163843.1571-1-vulab@iscas.ac.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251112062246.852-1-vulab@iscas.ac.cn> References: <20251112062246.852-1-vulab@iscas.ac.cn> 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 X-CM-TRANSID: rQCowABXcdhwPZdprW_cCA--.1041S2 X-Coremail-Antispam: 1UD129KBjvJXoW7trWDGw4fZw1xtrWxAw17GFg_yoW8Ar45pF W7KFWUtry8G3y09F1qyF1YgFy5uFn0k3y5t3yxKw4ruFnaqa45X3yUtFyFqFnruFWfZayU KF18tFWkJa18trJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkl14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r4j6ryUM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4j6r 4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWU AVWUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14 v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkG c2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI 0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4U MIIF0xvEx4A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7VUbSfO7UUUU U== X-CM-SenderInfo: pyxotu46lvutnvoduhdfq/1tbiDAYDA2mWpCeSvAACsa Content-Type: text/plain; charset="utf-8" hi3670_pcie_get_resources_from_pcie() leaks two references: 1) The OF node returned by of_get_child_by_name() is never released. 2) The device returned by bus_find_device_by_of_node() is never put. Fix both leaks by calling of_node_put() right after bus_find_device_by_of_node(), and put_device() after dev_get_regmap() when the temporary pcie_dev reference is no longer needed. Fixes: 73075011ffff ("phy: HiSilicon: Add driver for Kirin 970 PCIe PHY") Suggested-by: Vladimir Oltean Signed-off-by: Haotian Zhang --- Changes in v2: - Use explicit release instead of cleanup.h infrastructure. - Add put_device() for bus_find_device_by_of_node(). --- drivers/phy/hisilicon/phy-hi3670-pcie.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/phy/hisilicon/phy-hi3670-pcie.c b/drivers/phy/hisilico= n/phy-hi3670-pcie.c index dbc7dcce682b..35e634279794 100644 --- a/drivers/phy/hisilicon/phy-hi3670-pcie.c +++ b/drivers/phy/hisilicon/phy-hi3670-pcie.c @@ -570,6 +570,7 @@ static int hi3670_pcie_get_resources_from_pcie(struct h= i3670_pcie_phy *phy) } =20 pcie_dev =3D bus_find_device_by_of_node(&platform_bus_type, pcie_port); + of_node_put(pcie_port); if (!pcie_dev) { dev_err(dev, "Didn't find pcie device\n"); return -ENODEV; @@ -584,6 +585,7 @@ static int hi3670_pcie_get_resources_from_pcie(struct h= i3670_pcie_phy *phy) * right regmap. So, let's use the named version. */ phy->apb =3D dev_get_regmap(pcie_dev, "kirin_pcie_apb"); + put_device(pcie_dev); if (!phy->apb) { dev_err(dev, "Failed to get APB regmap\n"); return -ENODEV; --=20 2.43.0