From nobody Mon Feb 9 03:21:46 2026 Received: from mr85p00im-zteg06021501.me.com (mr85p00im-zteg06021501.me.com [17.58.23.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B55AB1DF97F for ; Fri, 13 Dec 2024 12:37:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.23.183 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734093443; cv=none; b=oCHXJBFHy7vZM40/rFKU8/yfQgflkZ+3EQcWow8hssXR9ozb8w8AcTpz1q75UQZAnDIB5Ad7pEvY6ug49GoAwasydHnHMiqUvASYTQSTutlsFw3DZ4NU7STABslcq6BYg2SzvbjObPNGrXnX5bF4bTQav6Vy1dJHXCd4Ukn/st8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734093443; c=relaxed/simple; bh=1aC21eRgtrQHuWt0TGHkjui+aELtSLGyaY7ee9ihTqI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NXBSoH1lPI1hE9BLKaIE/EPBWUaHX/4B2SqtaIntqsd6ic72or/oxbwzH0Qr0V842aYILYiaHYspEwRbCQvhCxBCr9BtP7+eys52WvDMu1MMbnwBLyzu5AaDSDWJIOy6cwgd3BpBHLw9cMempMIXgTnhJoWtqBkz0Cc50/47As4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=fCcdkbyJ; arc=none smtp.client-ip=17.58.23.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="fCcdkbyJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1734093441; bh=eoBflErfJ5YHnH9CNE+FKU4F+Kpr2DDHXom6su6dnH0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To: x-icloud-hme; b=fCcdkbyJSEtCGwzS72wGRUBVZHDv9Og+2KBDCZ1BIh40i5JINYTGuRivbJ06ZGhzm ZN4S5QkfGcca85vpkr5ix6SMgEFfCZbgqC+RE1V/HRR566EdbHYNZL8W7TdtfYR+Mg Xq6vfkQkUBWwZN8xSdKIZ0LdZvbfm8jL76LCC2K2nBnbjHao6M22l94ozhvL1kcTML T56jv3JV9iFl1jvpi+mI7gHB8huwZXa9FNHiDeaQ8CXyfqruRvdzwRolgXNrqyoYEb xPIKsThxn0SzZM4097WG6Ss+dXtpJ+m11Un/babxcE61QFrlOkkBTnA9kDFCh/FJnl B3TW3XjY6Eszw== Received: from [192.168.1.26] (mr38p00im-dlb-asmtp-mailmevip.me.com [17.57.152.18]) by mr85p00im-zteg06021501.me.com (Postfix) with ESMTPSA id 523552793D57; Fri, 13 Dec 2024 12:37:11 +0000 (UTC) From: Zijun Hu Date: Fri, 13 Dec 2024 20:36:41 +0800 Subject: [PATCH v6 1/6] phy: core: Fix that API devm_phy_put() fails to release the phy 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: <20241213-phy_core_fix-v6-1-40ae28f5015a@quicinc.com> References: <20241213-phy_core_fix-v6-0-40ae28f5015a@quicinc.com> In-Reply-To: <20241213-phy_core_fix-v6-0-40ae28f5015a@quicinc.com> To: Vinod Koul , Kishon Vijay Abraham I , Felipe Balbi , Greg Kroah-Hartman , Rob Herring , Arnd Bergmann , Lee Jones Cc: Greg Kroah-Hartman , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Bjorn Helgaas , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christophe JAILLET , Johan Hovold , Zijun Hu , stable@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Zijun Hu , Johan Hovold X-Mailer: b4 0.14.2 X-Proofpoint-ORIG-GUID: zx_KhUXQuellMpf8dLz_2dTS_YfoqjQg X-Proofpoint-GUID: zx_KhUXQuellMpf8dLz_2dTS_YfoqjQg X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-13_05,2024-12-12_03,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 bulkscore=0 clxscore=1015 mlxlogscore=999 adultscore=0 mlxscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2412130089 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu For devm_phy_put(), its comment says it needs to invoke phy_put() to release the phy, but it will not actually invoke the function since devres_destroy() does not call devm_phy_release(), and the missing phy_put() call will cause: - The phy fails to be released. - devm_phy_put() can not fully undo what API devm_phy_get() does. - Leak refcount of both the module and device for below typical usage: devm_phy_get(); // or its variant ... err =3D do_something(); if (err) goto err_out; ... err_out: devm_phy_put(); // leak refcount here The file(s) affected by this issue are shown below since they have such typical usage. drivers/pci/controller/cadence/pcie-cadence.c drivers/net/ethernet/ti/am65-cpsw-nuss.c Fix by using devres_release() instead of devres_destroy() within the API. Fixes: ff764963479a ("drivers: phy: add generic PHY framework") Cc: stable@vger.kernel.org Cc: Lorenzo Pieralisi Cc: Krzysztof Wilczy=C5=84ski Cc: Bjorn Helgaas Cc: David S. Miller Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Reviewed-by: Johan Hovold Signed-off-by: Zijun Hu --- drivers/phy/phy-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index f053b525ccffab1629f5e09581a6ebcc35e47f79..f190d7126613ad253b4820b9e41= 67dda8623439d 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -737,7 +737,7 @@ void devm_phy_put(struct device *dev, struct phy *phy) if (!phy) return; =20 - r =3D devres_destroy(dev, devm_phy_release, devm_phy_match, phy); + r =3D devres_release(dev, devm_phy_release, devm_phy_match, phy); dev_WARN_ONCE(dev, r, "couldn't find PHY resource\n"); } EXPORT_SYMBOL_GPL(devm_phy_put); --=20 2.34.1 From nobody Mon Feb 9 03:21:46 2026 Received: from mr85p00im-zteg06021501.me.com (mr85p00im-zteg06021501.me.com [17.58.23.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A5B51DFE08 for ; Fri, 13 Dec 2024 12:37:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.23.183 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734093452; cv=none; b=hJAY2gZamlLsB2c6g4r2O47BluHBCViQMPSx9ZAJJaBnz98CUes7FZ7Yk7LvnsC6OZZxV6AaWq2nrnonX2rk1pjikP8wO8mbVNvt5AV4NWX5OJbtNJdT8lveKoKwpY8kG/HphQSpeuo35xXGBxcEywdC6hlLLBvpyC3UFkdycv8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734093452; c=relaxed/simple; bh=UUkb6UWJy9dVmADx2/5U9/7j7WbVpZs33vJD+XTdxDM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oog2g52vTU8SfWyY6O8D5gDPZcnVzJ1/fcz3d9xH9LjuE0RIYlo5d8tdQZMCHaaV/yN3Kz/mgXL64GjRRcD8axE8YYkACXCtLu+NlNB8tck6juQb8F4Uk0znX4j5GH7ZtZcLx7HdFeNVmnwzC1FZXuYOHoOvhf0aYObSnP8ETMo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=mNEvKuCb; arc=none smtp.client-ip=17.58.23.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="mNEvKuCb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1734093450; bh=KAEa84k4ae1AAp04syMst+ARnTqenvGiw7Oz9H59tBM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To: x-icloud-hme; b=mNEvKuCb1lQjOrLHo4R10tK+X/Bvk8loRodTLH4mazxIenpdxQi04qSd8hkUJLEVa 5KBBTZjpEPdk6xaUKC1uUx9eqyhrVgHeMAuTy23XI8scdRObpivBgxkVWGPuCvkF2L qR4PKSf7MTeXCtqXRJB23RHCR5iVESNfNTac56tJidYAo9gbgA7JWClrpMSaJUoeag RZ5BDCmYFz0S0bkvNOa66wj3Sb/P0qJcO3A7AmAinU9SIIqpBkMI5YGLzw8/RNnX1e +njW2ftb0EkdNDfAZL7TPBsxI8Zmcb3ooFqgJdTurrMBzKxpbajZgZmuqx3Fqq/pMw 6r2O3B0xiZxgQ== Received: from [192.168.1.26] (mr38p00im-dlb-asmtp-mailmevip.me.com [17.57.152.18]) by mr85p00im-zteg06021501.me.com (Postfix) with ESMTPSA id DB3FF2793FB6; Fri, 13 Dec 2024 12:37:21 +0000 (UTC) From: Zijun Hu Date: Fri, 13 Dec 2024 20:36:42 +0800 Subject: [PATCH v6 2/6] phy: core: Fix that API devm_of_phy_provider_unregister() fails to unregister the phy provider 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: <20241213-phy_core_fix-v6-2-40ae28f5015a@quicinc.com> References: <20241213-phy_core_fix-v6-0-40ae28f5015a@quicinc.com> In-Reply-To: <20241213-phy_core_fix-v6-0-40ae28f5015a@quicinc.com> To: Vinod Koul , Kishon Vijay Abraham I , Felipe Balbi , Greg Kroah-Hartman , Rob Herring , Arnd Bergmann , Lee Jones Cc: Greg Kroah-Hartman , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Bjorn Helgaas , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christophe JAILLET , Johan Hovold , Zijun Hu , stable@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Zijun Hu , Johan Hovold X-Mailer: b4 0.14.2 X-Proofpoint-ORIG-GUID: v_a_AiZBMIwjWVGHSWCDMAyn0MPuwZIh X-Proofpoint-GUID: v_a_AiZBMIwjWVGHSWCDMAyn0MPuwZIh X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-13_05,2024-12-12_03,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 bulkscore=0 clxscore=1015 mlxlogscore=999 adultscore=0 mlxscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2412130089 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu For devm_of_phy_provider_unregister(), its comment says it needs to invoke of_phy_provider_unregister() to unregister the phy provider, but it will not actually invoke the function since devres_destroy() does not call devm_phy_provider_release(), and the missing of_phy_provider_unregister() call will cause: - The phy provider fails to be unregistered. - Leak both memory and the OF node refcount. Fortunately, the faulty API has not been used by current kernel tree. Fix by using devres_release() instead of devres_destroy() within the API. Fixes: ff764963479a ("drivers: phy: add generic PHY framework") Reviewed-by: Johan Hovold Signed-off-by: Zijun Hu --- Why to fix the API here instead of directly deleting it? 1) it is simpler, just one line change. 2) it may be used in future. 3) ensure this restored API right if need to restore it in future after deleting. Anyone may remove such APIs separately later if he/she cares. --- drivers/phy/phy-core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index f190d7126613ad253b4820b9e4167dda8623439d..de07e1616b34d12056024558124= f3ea2469c0323 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -1259,12 +1259,12 @@ EXPORT_SYMBOL_GPL(of_phy_provider_unregister); * of_phy_provider_unregister to unregister the phy provider. */ void devm_of_phy_provider_unregister(struct device *dev, - struct phy_provider *phy_provider) + struct phy_provider *phy_provider) { int r; =20 - r =3D devres_destroy(dev, devm_phy_provider_release, devm_phy_match, - phy_provider); + r =3D devres_release(dev, devm_phy_provider_release, devm_phy_match, + phy_provider); dev_WARN_ONCE(dev, r, "couldn't find PHY provider device resource\n"); } EXPORT_SYMBOL_GPL(devm_of_phy_provider_unregister); --=20 2.34.1 From nobody Mon Feb 9 03:21:46 2026 Received: from mr85p00im-zteg06021501.me.com (mr85p00im-zteg06021501.me.com [17.58.23.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1162A1CEAAC for ; Fri, 13 Dec 2024 12:37:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.23.183 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734093461; cv=none; b=mX9RYb5hkWRzvJdFjZPOOl0er78fQYWOLl0We4pd2BqEDWvo4qylD7bPaZ1vwg2pijjYqD/P3j6UWEMvBJvMxOk/NqccCvfNPaCUnqVE1dWklLcWTrE8qRRRQjwc2cqf0eSYwmgNanxJE6YRVZ0V2Xnmg2beObRj5JsKza8MnJY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734093461; c=relaxed/simple; bh=i/pvGmbejQ7Y2VVz20WYMnp2qBBnpzay5EjUCzFqOBs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VE11JXt5xXmmRb63crpZVpihGZrG6C0pLVQIj3kTMiKFFgiKGGCQK9sFi6B8KJNRdFiyjJjgGSftMUDWTNvpfV98eQChOWgw20nXk+7+d1HnfAHYkrK3OfqOUEMO6WPyk7+62n0PsDBgZvfbOIbQE/nKKK8oJZHDM2YE+Ph6Yuw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=Kguba0Y1; arc=none smtp.client-ip=17.58.23.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="Kguba0Y1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1734093459; bh=FvdkTxRCCic+u0D/ycct2THNC9tLn/b6kR+RvY6/y70=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To: x-icloud-hme; b=Kguba0Y1C6F46s7WdKWywICv38W8N8PtDGmQtRxPtc5+qWaQjRC2O0rtt1WO3dG79 C1K2p5t/MGXU7iDvNY2iNyZ6opvZ6M3+zKusBnKk9rS0dTyf4CpaBsdh2Te+om+rIB KqNrY2o3/zpgfCY+oyiczelwN65iNXhKcqzgTcNepmBnItWMK4oSeo7PZcFI5fKQv6 f0il8yCzLZZYEF1w9XepuZi+KgOgXFMc7vOcXoKla6pBK8SWJeISSvFQcgtD8prX72 Ibacxu5uJxshzMK/lcLALsPw/jN2jyfejSFlikCiElATaRzuAbB5ClCsjZjw8Uri/M igqXxMR3fttww== Received: from [192.168.1.26] (mr38p00im-dlb-asmtp-mailmevip.me.com [17.57.152.18]) by mr85p00im-zteg06021501.me.com (Postfix) with ESMTPSA id 3E0392793CF8; Fri, 13 Dec 2024 12:37:30 +0000 (UTC) From: Zijun Hu Date: Fri, 13 Dec 2024 20:36:43 +0800 Subject: [PATCH v6 3/6] phy: core: Fix that API devm_phy_destroy() fails to destroy the phy 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: <20241213-phy_core_fix-v6-3-40ae28f5015a@quicinc.com> References: <20241213-phy_core_fix-v6-0-40ae28f5015a@quicinc.com> In-Reply-To: <20241213-phy_core_fix-v6-0-40ae28f5015a@quicinc.com> To: Vinod Koul , Kishon Vijay Abraham I , Felipe Balbi , Greg Kroah-Hartman , Rob Herring , Arnd Bergmann , Lee Jones Cc: Greg Kroah-Hartman , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Bjorn Helgaas , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christophe JAILLET , Johan Hovold , Zijun Hu , stable@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Zijun Hu , Johan Hovold X-Mailer: b4 0.14.2 X-Proofpoint-ORIG-GUID: 3rcy8yTyNCAggnrEPM8caX2FB31AkD2D X-Proofpoint-GUID: 3rcy8yTyNCAggnrEPM8caX2FB31AkD2D X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-13_05,2024-12-12_03,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 bulkscore=0 clxscore=1015 mlxlogscore=999 adultscore=0 mlxscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2412130089 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu For devm_phy_destroy(), its comment says it needs to invoke phy_destroy() to destroy the phy, but it will not actually invoke the function since devres_destroy() does not call devm_phy_consume(), and the missing phy_destroy() call will cause that the phy fails to be destroyed. Fortunately, the faulty API has not been used by current kernel tree. Fix by using devres_release() instead of devres_destroy() within the API. Fixes: ff764963479a ("drivers: phy: add generic PHY framework") Reviewed-by: Johan Hovold Signed-off-by: Zijun Hu --- Why to fix the API here instead of directly deleting it? 1) it is simpler, just one line change. 2) it may be used in future. 3) ensure this restored API right if need to restore it in future after deleting. Anyone may remove such APIs separately later if he/she cares. --- drivers/phy/phy-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index de07e1616b34d12056024558124f3ea2469c0323..52ca590a58b9c303b21bf892565= 612a7ab92c095 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -1121,7 +1121,7 @@ void devm_phy_destroy(struct device *dev, struct phy = *phy) { int r; =20 - r =3D devres_destroy(dev, devm_phy_consume, devm_phy_match, phy); + r =3D devres_release(dev, devm_phy_consume, devm_phy_match, phy); dev_WARN_ONCE(dev, r, "couldn't find PHY resource\n"); } EXPORT_SYMBOL_GPL(devm_phy_destroy); --=20 2.34.1 From nobody Mon Feb 9 03:21:46 2026 Received: from mr85p00im-zteg06021501.me.com (mr85p00im-zteg06021501.me.com [17.58.23.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E492E1E048A for ; Fri, 13 Dec 2024 12:37:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.23.183 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734093470; cv=none; b=ZKp0jbJDeru6XrXBntQSqyaauh91aDyjAkASHQTdv4Y/vJDFUopV83+ZVW9biIQ4AJvGKjSjrqQEpRFpETw3onWNC1VSnWD3afLxlUcj2frJbJOkYDEynIjzf3CoC8TmE32JHy8x+Sh4ujTbpT7Td2OYsOZpzOx/Nj9i9ZJhY8k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734093470; c=relaxed/simple; bh=NZbAFdxpeagqFtzm5bKwXXLXgiLiEEZnFNLrVcYjWOQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UwtAPph5HJAhoEHcf5e+gsJ56HAPmasME8Jc8NKxDYRdxT9HTkW35A5PKtt9ToyY2YMaqGlPsP24QjdAv+Ds2O1T2c5p+DwSC7viNw7b8GfO8+d4gHDePgEh31fzLHLpeyPbY7cP+byZwdBj6I3qLP6ihzEI+L+WVyox/Q/wgCg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=JdwMQie4; arc=none smtp.client-ip=17.58.23.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="JdwMQie4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1734093468; bh=wyxreJ8ZOeQ11pLqAphuyUs2BXs2kHLB0q1+hs7nobY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To: x-icloud-hme; b=JdwMQie476kqVi74Ijs0Ss090VYMx6tic88LobqilcAt3RITK8waA2pkp5mEP5S3A YFtfXESe51cCYKEoM2YBQZHlq62VKEAaIQt8a56F5cISDJ4+AhH4x0Qlm1PILREY3w 6/nrS3GD7btp/WZhkuPTfUOl6gPyfuSmDgcZyKalGk2GvvwvZOseDHAiNkAZmdEUWo paJjCHcyGZix9I6MmoQgLd+xP3OWcA3HS+adQq3BMBwkCYg6DftlebYynQfn/7pV1w sVKV9q8WF9LdY4e2++BDeR3uJofpG5KU/1JlKCzSaIMVh6o0xnaHHkbmWd6JO+3G2B cONLFD2EqodtA== Received: from [192.168.1.26] (mr38p00im-dlb-asmtp-mailmevip.me.com [17.57.152.18]) by mr85p00im-zteg06021501.me.com (Postfix) with ESMTPSA id 2C22A2793DC6; Fri, 13 Dec 2024 12:37:39 +0000 (UTC) From: Zijun Hu Date: Fri, 13 Dec 2024 20:36:44 +0800 Subject: [PATCH v6 4/6] phy: core: Fix an OF node refcount leakage in _of_phy_get() 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: <20241213-phy_core_fix-v6-4-40ae28f5015a@quicinc.com> References: <20241213-phy_core_fix-v6-0-40ae28f5015a@quicinc.com> In-Reply-To: <20241213-phy_core_fix-v6-0-40ae28f5015a@quicinc.com> To: Vinod Koul , Kishon Vijay Abraham I , Felipe Balbi , Greg Kroah-Hartman , Rob Herring , Arnd Bergmann , Lee Jones Cc: Greg Kroah-Hartman , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Bjorn Helgaas , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christophe JAILLET , Johan Hovold , Zijun Hu , stable@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Zijun Hu , Johan Hovold X-Mailer: b4 0.14.2 X-Proofpoint-ORIG-GUID: JD-pS1O41hgJIkTIlLV-MtOWkkjA_jIb X-Proofpoint-GUID: JD-pS1O41hgJIkTIlLV-MtOWkkjA_jIb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-13_05,2024-12-12_03,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 bulkscore=0 clxscore=1015 mlxlogscore=999 adultscore=0 mlxscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2412130089 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu _of_phy_get() will directly return when suffers of_device_is_compatible() error, but it forgets to decrease refcount of OF node @args.np before error return, the refcount was increased by previous of_parse_phandle_with_args() so causes the OF node's refcount leakage. Fix by decreasing the refcount via of_node_put() before the error return. Fixes: b7563e2796f8 ("phy: work around 'phys' references to usb-nop-xceiv d= evices") Cc: stable@vger.kernel.org Reviewed-by: Johan Hovold Signed-off-by: Zijun Hu --- drivers/phy/phy-core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 52ca590a58b9c303b21bf892565612a7ab92c095..b88fbda6c046174b7abd0a0435e= c54763e9f42bc 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -629,8 +629,10 @@ static struct phy *_of_phy_get(struct device_node *np,= int index) return ERR_PTR(-ENODEV); =20 /* This phy type handled by the usb-phy subsystem for now */ - if (of_device_is_compatible(args.np, "usb-nop-xceiv")) - return ERR_PTR(-ENODEV); + if (of_device_is_compatible(args.np, "usb-nop-xceiv")) { + phy =3D ERR_PTR(-ENODEV); + goto out_put_node; + } =20 mutex_lock(&phy_provider_mutex); phy_provider =3D of_phy_provider_lookup(args.np); @@ -652,6 +654,7 @@ static struct phy *_of_phy_get(struct device_node *np, = int index) =20 out_unlock: mutex_unlock(&phy_provider_mutex); +out_put_node: of_node_put(args.np); =20 return phy; --=20 2.34.1 From nobody Mon Feb 9 03:21:46 2026 Received: from mr85p00im-zteg06021501.me.com (mr85p00im-zteg06021501.me.com [17.58.23.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B6E231E0B99 for ; Fri, 13 Dec 2024 12:37:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.23.183 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734093479; cv=none; b=FtHzzZu7mYq7SxLtY7Hh8Ym9KAJiyGM9yEi6IvGYw1goaYWLdl8u6bOyXLNMhDs3KZ8T2VMD/tskgWRgBrX+qpMpGqGepMlBKfFE/4kLIA8kI0qrTbgumxKjlYWnr0XW0/1BWqC7O9+OCLsonKoMrzm4eEtbt1sDIUGR0pyMwm0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734093479; c=relaxed/simple; bh=wlxILsGSDKkH5PDMybeitbVATSCeBlPxUXxnMRYZnWk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GE4OVknv8ZOAuHIcvztbcz2Bo/DR7ZrPFRmrbqDXpknbf/u3hd+bvDeuN1S2rp7ivQklzzRWoKvhLgCkSXqn7B03Q2hyX5KsK0Q2M+zCUz9czWHx6hw80tpPnNdtELQHG0xDY8eHL8Sh1B+qP+RxDfaSwCWRjxU5MR60r51pZMU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=xx+S+tjJ; arc=none smtp.client-ip=17.58.23.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="xx+S+tjJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1734093477; bh=vHF8DCKQH6/n7GK9DPqqodw58R039f9qaEE0YJ47Wlw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To: x-icloud-hme; b=xx+S+tjJSX/ndp7wqRkmyXmIOfMsUFc6Fnl2LDiY59ajeP8ZyW27AgSD9yvTfWSyy MldnwU25gn/W1ldQHdPsRDjV2fmqHQqKEfRkmgWcrJ48gFz8yqOZVNYG2WPCSIoyC7 igZMOWUQJ6slaTvSbGN7zTeHTSbv7Oe7nVL6pJpcKqpXT7U1mPAfzMGuzda9oE3pza +yp9t4EtLPIvgUDOeTnwYzPkyX01r8okP/t1Iz61Oj5u/FxU74uyAR/quesUSIiFrs 6dP6jz/Jd2V3pnOiBFkI9FG1ZW1CkZsIIkZCIBTGAlKCqcmE01TftTxxF+KMgX5/e6 TUbBV2DTbtR7w== Received: from [192.168.1.26] (mr38p00im-dlb-asmtp-mailmevip.me.com [17.57.152.18]) by mr85p00im-zteg06021501.me.com (Postfix) with ESMTPSA id 10F2A2793FE0; Fri, 13 Dec 2024 12:37:48 +0000 (UTC) From: Zijun Hu Date: Fri, 13 Dec 2024 20:36:45 +0800 Subject: [PATCH v6 5/6] phy: core: Fix an OF node refcount leakage in of_phy_provider_lookup() 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: <20241213-phy_core_fix-v6-5-40ae28f5015a@quicinc.com> References: <20241213-phy_core_fix-v6-0-40ae28f5015a@quicinc.com> In-Reply-To: <20241213-phy_core_fix-v6-0-40ae28f5015a@quicinc.com> To: Vinod Koul , Kishon Vijay Abraham I , Felipe Balbi , Greg Kroah-Hartman , Rob Herring , Arnd Bergmann , Lee Jones Cc: Greg Kroah-Hartman , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Bjorn Helgaas , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christophe JAILLET , Johan Hovold , Zijun Hu , stable@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Zijun Hu , Johan Hovold X-Mailer: b4 0.14.2 X-Proofpoint-ORIG-GUID: kkC14_aTfSvXZL-K-AObGaPtXdPiUX68 X-Proofpoint-GUID: kkC14_aTfSvXZL-K-AObGaPtXdPiUX68 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-13_05,2024-12-12_03,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 bulkscore=0 clxscore=1015 mlxlogscore=999 adultscore=0 mlxscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2412130089 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu For macro for_each_child_of_node(parent, child), refcount of @child has been increased before entering its loop body, so normally needs to call of_node_put(@child) before returning from the loop body to avoid refcount leakage. of_phy_provider_lookup() has such usage but does not call of_node_put() before returning, so cause leakage of the OF node refcount. Fix by simply calling of_node_put() before returning from the loop body. The APIs affected by this issue are shown below since they indirectly invoke problematic of_phy_provider_lookup(). phy_get() of_phy_get() devm_phy_get() devm_of_phy_get() devm_of_phy_get_by_index() Fixes: 2a4c37016ca9 ("phy: core: Fix of_phy_provider_lookup to return PHY p= rovider for sub node") Cc: stable@vger.kernel.org Reviewed-by: Johan Hovold Signed-off-by: Zijun Hu --- The following kernel mainline commit fixes a similar issue: Commit: b337cc3ce475 ("backlight: lm3509_bl: Fix early returns in for_each_= child_of_node()") --- drivers/phy/phy-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index b88fbda6c046174b7abd0a0435ec54763e9f42bc..413f76e2d1744dd8ffb63a6c3a0= 93f5c6cbead7b 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -145,8 +145,10 @@ static struct phy_provider *of_phy_provider_lookup(str= uct device_node *node) return phy_provider; =20 for_each_child_of_node(phy_provider->children, child) - if (child =3D=3D node) + if (child =3D=3D node) { + of_node_put(child); return phy_provider; + } } =20 return ERR_PTR(-EPROBE_DEFER); --=20 2.34.1 From nobody Mon Feb 9 03:21:46 2026 Received: from mr85p00im-zteg06021501.me.com (mr85p00im-zteg06021501.me.com [17.58.23.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A08E1DFD86 for ; Fri, 13 Dec 2024 12:38:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.23.183 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734093488; cv=none; b=tBrUR7tHqsFyG/JCjpHcwx/IVhnh9otTcCJOdO24w1Z+YAOKDmYzMgadUKL7EQru9/YwQa6QTLa4MO6RfFjqpi9J9JXqfVU5036kqYhvQTQU99GvQ5A1g2Xcwh2RHuzam+6qA/nTZdDeb6hCmF+uws4wDZxp7zryl118I0S2mao= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734093488; c=relaxed/simple; bh=/W4oRREVfsIlOphdKX84ARTWcwEEFb+L2b7zPiB9Fck=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ey+AOPGX54lgHxhLJxwuVWvgAIZvWGCffVDsDpDIxq6w1iQIRewLzrwt0udMkgesZ+Wi3hqW94tLtD/1vV7+G4vtp6dRaE43Sp4hCK7GTY/W894UuCUxGk2YvlCZzcZN8ElL/g8XlXJeyDkXP2deNyj/t/ZmFoXIvnRt5ko4etM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=GTPLGRqI; arc=none smtp.client-ip=17.58.23.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="GTPLGRqI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1734093486; bh=gAZiIBAW97iSqVxa0yzt2S2NKUuhI3+PKJU5sy0ohIM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To: x-icloud-hme; b=GTPLGRqI7p1Ug1WY1aEwDN1yujO59xixCqprE1ZG56aOCN7U68v4cuc4Ch2zXZAkN sg1zCwuNzK0bo1+vCD/XBDB6DBmyNkcby5lP8BWIwd2ZuWDSJBdh9T/nBh151AQw61 G9ec6MNgTav9ZpzCC7yhOC273s6iEocbnvYEF8ADLbNEjKSK5Cia+9h8C4KbH5NPfY Jom59IwQG3XT7TUQXZahOaiP8XfmBWbPu89fq3gdCD9zGi3fbbneUL0JQyME7gV9Fv 97nNftPHguBSu6PI6oCin36dAV7X1olD48w8k3waOe8DiFLAL1u47yZlmc4wb9x1Wa g4/RmMai0Lwwg== Received: from [192.168.1.26] (mr38p00im-dlb-asmtp-mailmevip.me.com [17.57.152.18]) by mr85p00im-zteg06021501.me.com (Postfix) with ESMTPSA id E31592793D1D; Fri, 13 Dec 2024 12:37:57 +0000 (UTC) From: Zijun Hu Date: Fri, 13 Dec 2024 20:36:46 +0800 Subject: [PATCH v6 6/6] phy: core: Simplify API of_phy_simple_xlate() implementation 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: <20241213-phy_core_fix-v6-6-40ae28f5015a@quicinc.com> References: <20241213-phy_core_fix-v6-0-40ae28f5015a@quicinc.com> In-Reply-To: <20241213-phy_core_fix-v6-0-40ae28f5015a@quicinc.com> To: Vinod Koul , Kishon Vijay Abraham I , Felipe Balbi , Greg Kroah-Hartman , Rob Herring , Arnd Bergmann , Lee Jones Cc: Greg Kroah-Hartman , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Bjorn Helgaas , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christophe JAILLET , Johan Hovold , Zijun Hu , stable@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Zijun Hu , Simon Horman X-Mailer: b4 0.14.2 X-Proofpoint-ORIG-GUID: 2JINNleipOqtTWVGoJDHTzZH0QuUezzf X-Proofpoint-GUID: 2JINNleipOqtTWVGoJDHTzZH0QuUezzf X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-13_05,2024-12-12_03,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 bulkscore=0 clxscore=1015 mlxlogscore=999 adultscore=0 mlxscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2412130089 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu Simplify of_phy_simple_xlate() implementation by API class_find_device_by_of_node(). Also correct comments to mark its parameter @dev as unused instead of @args in passing. Signed-off-by: Zijun Hu Cc: Simon Horman --- drivers/phy/phy-core.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 413f76e2d1744dd8ffb63a6c3a093f5c6cbead7b..8dfdce605a905d7f38205727151= 258af41f807a9 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -749,8 +749,8 @@ EXPORT_SYMBOL_GPL(devm_phy_put); =20 /** * of_phy_simple_xlate() - returns the phy instance from phy provider - * @dev: the PHY provider device - * @args: of_phandle_args (not used here) + * @dev: the PHY provider device (not used here) + * @args: of_phandle_args * * Intended to be used by phy provider for the common case where #phy-cell= s is * 0. For other cases where #phy-cells is greater than '0', the phy provid= er @@ -760,21 +760,14 @@ EXPORT_SYMBOL_GPL(devm_phy_put); struct phy *of_phy_simple_xlate(struct device *dev, const struct of_phandle_args *args) { - struct phy *phy; - struct class_dev_iter iter; - - class_dev_iter_init(&iter, &phy_class, NULL, NULL); - while ((dev =3D class_dev_iter_next(&iter))) { - phy =3D to_phy(dev); - if (args->np !=3D phy->dev.of_node) - continue; + struct device *target_dev; =20 - class_dev_iter_exit(&iter); - return phy; - } + target_dev =3D class_find_device_by_of_node(&phy_class, args->np); + if (!target_dev) + return ERR_PTR(-ENODEV); =20 - class_dev_iter_exit(&iter); - return ERR_PTR(-ENODEV); + put_device(target_dev); + return to_phy(target_dev); } EXPORT_SYMBOL_GPL(of_phy_simple_xlate); =20 --=20 2.34.1