From: Zijun Hu <zijun_hu@icloud.com>
To: Vinod Koul <vkoul@kernel.org>,
Kishon Vijay Abraham I <kishon@kernel.org>,
Felipe Balbi <balbi@ti.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Rob Herring <robh@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
Lee Jones <lee@kernel.org>
Cc: "Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Christophe JAILLET" <christophe.jaillet@wanadoo.fr>,
"Johan Hovold" <johan@kernel.org>,
"Zijun Hu" <zijun_hu@icloud.com>,
stable@vger.kernel.org, linux-phy@lists.infradead.org,
linux-kernel@vger.kernel.org,
"Zijun Hu" <quic_zijuhu@quicinc.com>
Subject: [PATCH v4 3/6] phy: core: Fix that API devm_phy_destroy() fails to destroy the phy
Date: Sat, 02 Nov 2024 11:53:45 +0800 [thread overview]
Message-ID: <20241102-phy_core_fix-v4-3-4f06439f61b1@quicinc.com> (raw)
In-Reply-To: <20241102-phy_core_fix-v4-0-4f06439f61b1@quicinc.com>
From: Zijun Hu <quic_zijuhu@quicinc.com>
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 case that the phy fails to be destroyed.
Fortunately, the faulty API has not been used by current kernel tree.
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 <quic_zijuhu@quicinc.com>
---
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 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);
--
2.34.1
next prev parent reply other threads:[~2024-11-02 3:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-02 3:53 [PATCH v4 0/6] phy: core: Fix bugs for several APIs and simplify an API Zijun Hu
2024-11-02 3:53 ` [PATCH v4 1/6] phy: core: Fix that API devm_phy_put() fails to release the phy Zijun Hu
2024-11-05 17:13 ` Johan Hovold
2024-11-02 3:53 ` [PATCH v4 2/6] phy: core: Fix that API devm_of_phy_provider_unregister() fails to unregister the phy provider Zijun Hu
2024-11-05 17:15 ` Johan Hovold
2024-11-02 3:53 ` Zijun Hu [this message]
2024-11-05 17:17 ` [PATCH v4 3/6] phy: core: Fix that API devm_phy_destroy() fails to destroy the phy Johan Hovold
2024-11-02 3:53 ` [PATCH v4 4/6] phy: core: Fix an OF node refcount leakage in _of_phy_get() Zijun Hu
2024-11-05 17:20 ` Johan Hovold
2024-11-06 15:28 ` Zijun Hu
2024-11-02 3:53 ` [PATCH v4 5/6] phy: core: Fix an OF node refcount leakage in of_phy_provider_lookup() Zijun Hu
2024-11-02 3:53 ` [PATCH v4 6/6] phy: core: Simplify API of_phy_simple_xlate() implementation Zijun Hu
2024-11-02 3:57 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241102-phy_core_fix-v4-3-4f06439f61b1@quicinc.com \
--to=zijun_hu@icloud.com \
--cc=arnd@arndb.de \
--cc=balbi@ti.com \
--cc=bhelgaas@google.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=johan@kernel.org \
--cc=kishon@kernel.org \
--cc=kuba@kernel.org \
--cc=kw@linux.com \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=lpieralisi@kernel.org \
--cc=pabeni@redhat.com \
--cc=quic_zijuhu@quicinc.com \
--cc=robh@kernel.org \
--cc=stable@vger.kernel.org \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox