From patchwork Sun Oct 20 05:27:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zijun Hu X-Patchwork-Id: 13842988 Received: from pv50p00im-hyfv10021501.me.com (pv50p00im-hyfv10021501.me.com [17.58.6.48]) (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 C3EE917C79 for ; Sun, 20 Oct 2024 05:28:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729402111; cv=none; b=GvoziB6PfcJ1aH6EsHfNhczLJLcDgc8Z+rOVqB9WPUeQxSmvg01SN01G6db7H7lsDx6SzDhKniy9iNcAsd9D/sh+j91qSsRqOuBZDI/2SbbkD5RJCQw+aC5txKzKOBw83lptP25fzh3iOd12liqlCxEmHKoifocJNbMz75x9P4I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729402111; c=relaxed/simple; bh=yRlI5ZQbFQSAjN5ZN2BqMJNtRWxWQcPeZJrENtttJJo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=H4I0+ER+xZSPygcF/AecFpGvRKcqrrugW6481AiUJFbQFUkX3SzJWi0/cPlLV12anKJS1pbt3+RAP5HMrut+ahIIHVdEbvvens3Pevp/g5Qt0d7T+jWOjBjBzbudLGgfoEMkximB30hZoqeO5XB3PPp/rzAJEeABqYXYx0imxIc= 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=Yfh2oBZa; arc=none smtp.client-ip=17.58.6.48 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="Yfh2oBZa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1729402109; bh=KnWmUxlYWWRbTvdeYT3kWc/oYa/wGqdAwM1ag6tzhOY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To; b=Yfh2oBZanXoWXjDU7Yt67Qlkt/SaoaBWFzJwQJXGpmjrNQMCsvnd+owTYQVy9mlqY cgavEfm+Oe/uyPfX5gRM1UYXQVjqQbE9GxBzRR8PcJ3dIi6EQPVLfjJq1RDy26eYH9 lV7hA8oqs+SS7UM3n+i6Epg3EYUPsYinm5tZW4xH6lqmXqPnLP8Mm9Q71NyOHJNr58 lzQFtugZMN93Dnk8t/QmgYqcuLyfFPye3lcV3tDsr9wl+t/45phSrCGcvOAMTkePX8 cYmfs6xLMbkaN0CkQK9VVqPSkSQqqUO0pZnYhdUPImepRcemYBb4LK3xbQqV41cG8A dBYc+GcN/PldQ== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-hyfv10021501.me.com (Postfix) with ESMTPSA id 95ACB2C00F7; Sun, 20 Oct 2024 05:28:23 +0000 (UTC) From: Zijun Hu Date: Sun, 20 Oct 2024 13:27:46 +0800 Subject: [PATCH 1/6] phy: core: Fix API devm_phy_put() can not release the phy Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241020-phy_core_fix-v1-1-078062f7da71@quicinc.com> References: <20241020-phy_core_fix-v1-0-078062f7da71@quicinc.com> In-Reply-To: <20241020-phy_core_fix-v1-0-078062f7da71@quicinc.com> To: Vinod Koul , Kishon Vijay Abraham I , Felipe Balbi , Greg Kroah-Hartman , Rob Herring , Arnd Bergmann , Lee Jones Cc: Zijun Hu , stable@vger.kernel.org, linux-phy@lists.infradead.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.1 X-Proofpoint-ORIG-GUID: gv-M2zT64WpCFnIo56TxGzChfILMIwkn X-Proofpoint-GUID: gv-M2zT64WpCFnIo56TxGzChfILMIwkn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-20_02,2024-10-17_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 spamscore=0 malwarescore=0 phishscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2410200032 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 does not do that actually, so it can not fully undo what the API devm_phy_get() does, that is wrong, fixed by using devres_release() instead of devres_destroy() within the API. BTW, the API is directly used by below source files in error handling path, so also fix relevant issue within these source files: drivers/pci/controller/cadence/pcie-cadence.c drivers/net/ethernet/ti/am65-cpsw-nuss.c Fixes: ff764963479a ("drivers: phy: add generic PHY framework") Cc: stable@vger.kernel.org Cc: netdev@vger.kernel.org Cc: linux-pci@vger.kernel.org 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 f053b525ccff..f190d7126613 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; - r = devres_destroy(dev, devm_phy_release, devm_phy_match, phy); + r = 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); From patchwork Sun Oct 20 05:27:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zijun Hu X-Patchwork-Id: 13842989 Received: from pv50p00im-hyfv10021501.me.com (pv50p00im-hyfv10021501.me.com [17.58.6.48]) (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 E488E2B9B4 for ; Sun, 20 Oct 2024 05:28:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729402117; cv=none; b=O5xZTluzADlX/C3fNBBR8jD3e4zYPcH1UoP1hUCoE+b3EBRelQdJevi8eO7x40oCbh6GRzfZ/Wr1yetM1URjXGT2lCaU7G0lkjsM56WAS/iO0dektR4qZ/YzZEdmWEUJA9f+V5JpDolaK1qHEZXJYlDWJDBu2koMLrM+nByvWbs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729402117; c=relaxed/simple; bh=8SmFoDvziLTkoomNOE0R+322rxR2P5PDpK1upfDV1CE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WXK0GSV6dZFDhiG5mLFKRapFOGY6VGNwytlA5nlycKHRDf8qSHWFnLedHjO2pjZfkHVxI5I4a+PfnsoXZ1cjyP03PIEaZtr/qJFIu8w9yxdjuBqH+YgkYswqq/7EpcX/Z1v3FEnSz/WnY86ekv8JBSs2Sqop84V82vkIGUCyObc= 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=Q63jTXse; arc=none smtp.client-ip=17.58.6.48 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="Q63jTXse" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1729402115; bh=/56WqmOxBRcMrRRa1vGi/MoooLtUKmliYmk1pSnTxZg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To; b=Q63jTXseUlZM5zGMoEAcD3TCLGKT4z1uctoS3tY42/SWQMCODg1fSeWrmtsTCNzEg omfKpnFSannVfDGabpksUdpRiWec6dAMe//2WObN5hmGKqEWEnEepeTv3tUyeLhVqb JBiLEZrU4MQ9j34cIzab57GqaXoVCzInghDlWCz+7umB8v6ckVrZKJsPAGnwAKzbGY FkWiAeBkcJylCxxoGexq227OnoVajqG4GiqfQjA3Jm2ZDueBoK98JH2oydMsUAI1ny 3RTPsQMshZYlR9II7p5op2bfczG2TJ5apWXvYBkFYLHajgEAqKFmuxj8aBCMo7SZxc ol0y+3rlnKrtA== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-hyfv10021501.me.com (Postfix) with ESMTPSA id E90132C00D3; Sun, 20 Oct 2024 05:28:29 +0000 (UTC) From: Zijun Hu Date: Sun, 20 Oct 2024 13:27:47 +0800 Subject: [PATCH 2/6] phy: core: Fix API devm_of_phy_provider_unregister() can not unregister the phy provider Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241020-phy_core_fix-v1-2-078062f7da71@quicinc.com> References: <20241020-phy_core_fix-v1-0-078062f7da71@quicinc.com> In-Reply-To: <20241020-phy_core_fix-v1-0-078062f7da71@quicinc.com> To: Vinod Koul , Kishon Vijay Abraham I , Felipe Balbi , Greg Kroah-Hartman , Rob Herring , Arnd Bergmann , Lee Jones Cc: Zijun Hu , stable@vger.kernel.org, linux-phy@lists.infradead.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.1 X-Proofpoint-ORIG-GUID: hazZhiyjtEeOvE2ZPoxwF1ec4un2usrl X-Proofpoint-GUID: hazZhiyjtEeOvE2ZPoxwF1ec4un2usrl X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-20_02,2024-10-17_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 spamscore=0 malwarescore=0 phishscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2410200032 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 does not do that actually, so it can not fully undo what the API devm_of_phy_provider_register() does, that is wrong, fixed by using devres_release() instead of devres_destroy() within the API. Fixes: ff764963479a ("drivers: phy: add generic PHY framework") Cc: stable@vger.kernel.org Signed-off-by: Zijun Hu --- 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 f190d7126613..de07e1616b34 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; - r = devres_destroy(dev, devm_phy_provider_release, devm_phy_match, - phy_provider); + r = 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); From patchwork Sun Oct 20 05:27:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zijun Hu X-Patchwork-Id: 13842990 Received: from pv50p00im-hyfv10021501.me.com (pv50p00im-hyfv10021501.me.com [17.58.6.48]) (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 5C5AC3B2BB for ; Sun, 20 Oct 2024 05:28:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729402123; cv=none; b=sQ8iCzEO2SpDe2B4B0tQ2XutuIHeArHCDjKwwKQXls+2iXvtyQDT/3NbJFXmzvVxKcGXQyNX08ezURJBqMfIQqUKmjp7k1N+xLc+0hz86Gn9i+3FOc6rhNnFbabB+irm+53nkD8gqaAJThYZVQ+4XtJ/Tiju/jQPcicBEFaNkJ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729402123; c=relaxed/simple; bh=ZOEJdZ+Y3uBV1dJVvv1OBBlfxG/5hZGvIhfygbRzcEs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lQPjku+vYjBiRYJkTPYtKj+l1vj7yawlh48mermZntVTl4OjVmBGp8CT2zCDRgCcWDl64o4EmOdqB48fmY37Y+7s4IvJENvrUnSeFlvA/yg2jH8UICs56VYOYM68U7w10gL0H7C4OixWxdpdIwm4EeD/O3vKxTh+1BPWOuVNXyo= 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=agl/5G5a; arc=none smtp.client-ip=17.58.6.48 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="agl/5G5a" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1729402121; bh=4UkJl6ESTHl0MKzkJU4NiOf/LCaIG4/FzrobNoV6pGo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To; b=agl/5G5aRiA/jFm9Z5d6jJMG/1kcv7KbHcP1dOJ30kvE9JiD6zhw22+qXm3HiR7ps Wy2Wh0ZdOeP2xGhQYTTsxqfDQrpBorcxcjs0mi1EzdW4uSEmwsE2pTIjOfb7T+jLmB tohHnrKZ6m0KxnHZO3hIUwK0ZLKmYY7/lDP9LKtc6h2EgpjeG61ZsxkmZTCU1l1RxO YBU7LTQT/G3D2VxNdDC/MXLKV2XLw/8RZDgeAbCF5csG6U87xZhT4sQCXD8U3S1U4E KI7UAvMi1Gn+yVFWW5RwGV3QwQMPbN6oAvOWKs2en5yJYJCBn3cGHM+8Ui/hpTt7i+ VdDEGYC/OvQwA== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-hyfv10021501.me.com (Postfix) with ESMTPSA id 3E7BC2C0130; Sun, 20 Oct 2024 05:28:35 +0000 (UTC) From: Zijun Hu Date: Sun, 20 Oct 2024 13:27:48 +0800 Subject: [PATCH 3/6] phy: core: Fix API devm_phy_destroy() can not destroy the phy Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241020-phy_core_fix-v1-3-078062f7da71@quicinc.com> References: <20241020-phy_core_fix-v1-0-078062f7da71@quicinc.com> In-Reply-To: <20241020-phy_core_fix-v1-0-078062f7da71@quicinc.com> To: Vinod Koul , Kishon Vijay Abraham I , Felipe Balbi , Greg Kroah-Hartman , Rob Herring , Arnd Bergmann , Lee Jones Cc: Zijun Hu , stable@vger.kernel.org, linux-phy@lists.infradead.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.1 X-Proofpoint-ORIG-GUID: U-x97Lqmim6E_t_TfbzbHgSP6RIq63vt X-Proofpoint-GUID: U-x97Lqmim6E_t_TfbzbHgSP6RIq63vt X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-20_02,2024-10-17_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 spamscore=0 malwarescore=0 phishscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2410200032 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 does not do that actually, so it can not fully undo what the API devm_phy_create() does, that is wrong, fixed by using devres_release() instead of devres_destroy() within the API. Fixes: ff764963479a ("drivers: phy: add generic PHY framework") Cc: stable@vger.kernel.org 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 de07e1616b34..52ca590a58b9 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; - r = devres_destroy(dev, devm_phy_consume, devm_phy_match, phy); + r = 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); From patchwork Sun Oct 20 05:27:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zijun Hu X-Patchwork-Id: 13842991 Received: from pv50p00im-hyfv10021501.me.com (pv50p00im-hyfv10021501.me.com [17.58.6.48]) (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 7EDCD14A85 for ; Sun, 20 Oct 2024 05:28:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729402129; cv=none; b=D58+mjy+KS1vgkqP8sqGQDyci62VCRuuuyinzeQJQuUceZQ/5iTLchOuOSzqF92WmADRlWHYBfl5e9j3DJrM+7b1VpCJhVlA/q1zBWtQhYHB9r+XKr9HSbkrPOD1Jsyu6LKhi6LWmtevnN1pT7k6HKi2+Hq1MdayKzHaW84BbaI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729402129; c=relaxed/simple; bh=zw3V8T7ov+wsHzKci7EhxMWXZ+pU508pS/bnECLKxOU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=X4wCRYcAbd0gD2JZmDr45a27C5b4KtSmrSlWGwUEbvUOQOFhjMvid5WLjRJbSIEXs52iuy4Ylvrj83+wdf0aqIjBiwMHxDAEcqW5UgQ+y5kxHZNxsFJo4NNoUCkgDAoh+0vpp+lnyA4oyDJ10h7v4O3V3YasV01otSUqd0R5HZw= 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=gpwA6Neb; arc=none smtp.client-ip=17.58.6.48 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="gpwA6Neb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1729402128; bh=bqgD9TqeRl3fISVSF8RjYIENXrO/0dTFirpvQNfH4Dk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To; b=gpwA6Nebi6sHyPqVwriErkrRAhyENlFTXgZcArARP8mEwzKBlNqcKlFYAJFtkECLL ya6kIrNGTXEdErFwr9yHehnypMbo9TDrumZZVglnayEeMonZDR5aZs/1tiJDj2Fw9+ J3ydjynv9shdosxmzgJvzSjJPXAjWXXdlUQ+szT2HoIjJhJYbHqH6eXd1vvyxofr2f GmoO62berrK2gd/Yg3SXJDmt9x+R3qrzq0AgXDWFse12ZjC6bDj+QnAWaW6//FYFKY gNmBNGcpgnjES50eYR2OZ5vIeOUL4gQ8+J7hbss9dMaXasTJCXA6ivJJwcJs6DTzZa vefo6h7EQZJsg== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-hyfv10021501.me.com (Postfix) with ESMTPSA id 7D78D2C013F; Sun, 20 Oct 2024 05:28:42 +0000 (UTC) From: Zijun Hu Date: Sun, 20 Oct 2024 13:27:49 +0800 Subject: [PATCH 4/6] phy: core: Add missing of_node_put() for an error handling path of _of_phy_get() Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241020-phy_core_fix-v1-4-078062f7da71@quicinc.com> References: <20241020-phy_core_fix-v1-0-078062f7da71@quicinc.com> In-Reply-To: <20241020-phy_core_fix-v1-0-078062f7da71@quicinc.com> To: Vinod Koul , Kishon Vijay Abraham I , Felipe Balbi , Greg Kroah-Hartman , Rob Herring , Arnd Bergmann , Lee Jones Cc: Zijun Hu , stable@vger.kernel.org, linux-phy@lists.infradead.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.1 X-Proofpoint-ORIG-GUID: UKGJg6bDUiFHKz2zU5QVA92RCrgayaQo X-Proofpoint-GUID: UKGJg6bDUiFHKz2zU5QVA92RCrgayaQo X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-20_02,2024-10-17_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 spamscore=0 malwarescore=0 phishscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2410200032 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu It is wrong for _of_phy_get() not to decrease the OF node refcount which was increased by previous of_parse_phandle_with_args() when returns due to of_device_is_compatible() error. Fixed by adding of_node_put() before the error return. Fixes: b7563e2796f8 ("phy: work around 'phys' references to usb-nop-xceiv devices") Cc: stable@vger.kernel.org Signed-off-by: Zijun Hu --- drivers/phy/phy-core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 52ca590a58b9..967878b78797 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -629,8 +629,11 @@ static struct phy *_of_phy_get(struct device_node *np, int index) return ERR_PTR(-ENODEV); /* This phy type handled by the usb-phy subsystem for now */ - if (of_device_is_compatible(args.np, "usb-nop-xceiv")) + if (of_device_is_compatible(args.np, "usb-nop-xceiv")) { + /* Put refcount above of_parse_phandle_with_args() got */ + of_node_put(args.np); return ERR_PTR(-ENODEV); + } mutex_lock(&phy_provider_mutex); phy_provider = of_phy_provider_lookup(args.np); From patchwork Sun Oct 20 05:27:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zijun Hu X-Patchwork-Id: 13842992 Received: from pv50p00im-hyfv10021501.me.com (pv50p00im-hyfv10021501.me.com [17.58.6.48]) (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 CD1BF17C64 for ; Sun, 20 Oct 2024 05:28:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729402136; cv=none; b=VTgU0hDDjXMwjmyMQY9JTuSCVtXirvY9nVbeZaTpMir4LA4wVaNb11HHFlSqIrux+yFD4UlRFLfRMNyXGtxkbrIjanwvc28aZiXwvZ+9DVex9IejhXFOCfIHV5JSuMW2oTZSH7uZxWhHM7A8uxzSeee8c8LAONtTC9b5bKQpnpI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729402136; c=relaxed/simple; bh=yLaDk8wi94a039VFqD35D/AkXGEihK7L1eKOgEgRtOg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sRLttXeoezNhz57R+MdksXRNgjONL+Vj373XO0ScKyThplaLdORAxHj1ISQJrg4CIDy2A5x2FuSfBSNJh5gfowYHCZvSk6Wp2DAaf3iyJYJPGGs3FDvqdfJirDU2gxRciakodks/idp+VxewO6/xZMR+O2ZrX3h0vXur9mFQ608= 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=ou5YHP16; arc=none smtp.client-ip=17.58.6.48 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="ou5YHP16" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1729402134; bh=rVON13sMMqtKSwCrl4E1Uhkm6hLNfvRtGi981NVB7Gs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To; b=ou5YHP16ry9CgCybtpG62r35ZB2cpiklwmT1he10nlofB7CO0oQAY7P6knGVfStrr yBHd4FL3CbryCTpHZiGvlUqpAwIJuCz1SGhnCSMegnb0s4chbCotaXY5qCM7iwVsNm x9gTXClBdLxoOSTIa/hsOwn5k/IFUpuhe8+O84o2bpcvE9ZNYahhHOm/NMzj5flyGg Gu69Wosh8q8FpXgoaGr5LnQQpxlJcHOliGHy+88OWLHps3KIDYPV0MJ8y0AbgpBwuY p4f0Qq0jSPQ1Ae9OWaKCljqZAv3IVssLla7cnWNzd4dazBw8+ni3tVqzaGCfj3xMCd fj92LWGujUoww== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-hyfv10021501.me.com (Postfix) with ESMTPSA id CD6C22C0130; Sun, 20 Oct 2024 05:28:48 +0000 (UTC) From: Zijun Hu Date: Sun, 20 Oct 2024 13:27:50 +0800 Subject: [PATCH 5/6] phy: core: Add missing of_node_put() in of_phy_provider_lookup() Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241020-phy_core_fix-v1-5-078062f7da71@quicinc.com> References: <20241020-phy_core_fix-v1-0-078062f7da71@quicinc.com> In-Reply-To: <20241020-phy_core_fix-v1-0-078062f7da71@quicinc.com> To: Vinod Koul , Kishon Vijay Abraham I , Felipe Balbi , Greg Kroah-Hartman , Rob Herring , Arnd Bergmann , Lee Jones Cc: Zijun Hu , stable@vger.kernel.org, linux-phy@lists.infradead.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.1 X-Proofpoint-ORIG-GUID: hKZD5y-4RY3sylApKTy1YAx6Oj9Jx6jl X-Proofpoint-GUID: hKZD5y-4RY3sylApKTy1YAx6Oj9Jx6jl X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-20_02,2024-10-17_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 spamscore=0 malwarescore=0 phishscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2410200032 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu The for_each_child_of_node() macro automatically decrements the child refcount at the end of every iteration. On early exits, of_node_put() must be used to manually decrement the refcount and avoid memory leaks. The macro called by of_phy_provider_lookup() has such early exit, but it does not call of_node_put() before early exit. Fixed by adding missing of_node_put() in of_phy_provider_lookup(). Fixes: 2a4c37016ca9 ("phy: core: Fix of_phy_provider_lookup to return PHY provider for sub node") Cc: stable@vger.kernel.org Signed-off-by: Zijun Hu --- The impact of this change is wide since of_phy_provider_lookup() is indirectly called by APIs phy_get(), of_phy_get(), and devm_of_phy_get_by_index(). The following kernel mainline commit has similar fix: Commit: b337cc3ce475 ("backlight: lm3509_bl: Fix early returns in for_each_child_of_node()") --- drivers/phy/phy-core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 967878b78797..24bd619a33dd 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -143,10 +143,11 @@ static struct phy_provider *of_phy_provider_lookup(struct device_node *node) list_for_each_entry(phy_provider, &phy_provider_list, list) { if (phy_provider->dev->of_node == node) return phy_provider; - for_each_child_of_node(phy_provider->children, child) - if (child == node) + if (child == node) { + of_node_put(child); return phy_provider; + } } return ERR_PTR(-EPROBE_DEFER); From patchwork Sun Oct 20 05:27:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zijun Hu X-Patchwork-Id: 13842993 Received: from pv50p00im-hyfv10021501.me.com (pv50p00im-hyfv10021501.me.com [17.58.6.48]) (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 24FEC1C6B8 for ; Sun, 20 Oct 2024 05:29:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729402142; cv=none; b=YMlEGzqmOgVFSSQc/De11iNSXToZ/a8p/Raz3dW8AxazwsMwGlAIiS1J9UCDDBKNagefCZUbcA70oq5iktkrUwkwXfId6RlQ6mXZS62YDntOAThY3gdMhgZXKxlrdMcIiJj3FUeelmxQB2kn3QK7fQjnryPQKtmV+4eDDmQ1qHE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729402142; c=relaxed/simple; bh=KAQIPjHa1pT2Qv7ml02HoE4WShDt3Q6Tb2e8TvTKe6g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nVi0Aehgj6vn0KCuSVBR6cHLQCMvBkw+Hg91e2LeJ8bCACPxnMacdZfWiDY0hzD94haPMoISocnl0T7txBrgbNfynNxX1WMUu4x++1CuVOZUN0L8ZS7c7Wf7KZraUKs4F1z9oK+0Sd4Tp4f8Y0czA3yNLDVUqu6cw6EnB6FTPqo= 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=FzsUprEn; arc=none smtp.client-ip=17.58.6.48 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="FzsUprEn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1729402140; bh=Pzj4HJoWnL6JTLVf/LzhBRoFLqsQjjCajmU0HHRJmCM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To; b=FzsUprEnaIdjyWcgh24n4owqgCzwCEevOvHP5TBSaiI+GpFyVFF48q7MSLp5srmER 49VkFoBQ5XoQpE1j98Fz9ev9yh+BpUPjVvlh2BafPiLQAfKq2SsJQ07ku9Ojbg/XP2 qQjJHhxdEPOqQNcrLMXTrx5ZDPZaVo46b169DrWuHQ7/ae1Hvj/yoA0J4KYc6WN3H5 jtMwQfYBRhwhSywsNxKuMi4qXJ3zMT5IUD10mNexJhH0YpjHb6B0tjQL/CKMBbFHoH a5N7/J7iztEt7vk1VaMooWxFcs+nn+rmK9i3u80xPHGABylS8yFXBCxdO4oGvU8vqs Vz/Asg70Uh8Zg== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-hyfv10021501.me.com (Postfix) with ESMTPSA id 24D4C2C0141; Sun, 20 Oct 2024 05:28:54 +0000 (UTC) From: Zijun Hu Date: Sun, 20 Oct 2024 13:27:51 +0800 Subject: [PATCH 6/6] phy: core: Simplify API of_phy_simple_xlate() implementation Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241020-phy_core_fix-v1-6-078062f7da71@quicinc.com> References: <20241020-phy_core_fix-v1-0-078062f7da71@quicinc.com> In-Reply-To: <20241020-phy_core_fix-v1-0-078062f7da71@quicinc.com> To: Vinod Koul , Kishon Vijay Abraham I , Felipe Balbi , Greg Kroah-Hartman , Rob Herring , Arnd Bergmann , Lee Jones Cc: Zijun Hu , stable@vger.kernel.org, linux-phy@lists.infradead.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.1 X-Proofpoint-ORIG-GUID: 0V1SomLf6-r1ySnqSOHR_zWePw_E5J9r X-Proofpoint-GUID: 0V1SomLf6-r1ySnqSOHR_zWePw_E5J9r X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-20_02,2024-10-17_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 spamscore=0 malwarescore=0 phishscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2410200032 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() which is also safer since it subsys_get() @phy_class subsystem firstly then iterates devices. Also comment its parameter @dev with unused in passing since the parameter provides no available input info but acts as an auto variable. Signed-off-by: Zijun Hu --- drivers/phy/phy-core.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 24bd619a33dd..102fc6b6ff71 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -748,7 +748,7 @@ EXPORT_SYMBOL_GPL(devm_phy_put); /** * of_phy_simple_xlate() - returns the phy instance from phy provider - * @dev: the PHY provider device + * @dev: the PHY provider device unused * @args: of_phandle_args (not used here) * * Intended to be used by phy provider for the common case where #phy-cells is @@ -759,20 +759,13 @@ 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 = class_dev_iter_next(&iter))) { - phy = to_phy(dev); - if (args->np != phy->dev.of_node) - continue; + struct device *target_dev; - class_dev_iter_exit(&iter); - return phy; + target_dev = class_find_device_by_of_node(&phy_class, args->np); + if (target_dev) { + put_device(target_dev); + return to_phy(target_dev); } - - class_dev_iter_exit(&iter); return ERR_PTR(-ENODEV); } EXPORT_SYMBOL_GPL(of_phy_simple_xlate);