[PATCH v5 3/8] phy: core: Make phy_put() ignore NULL and error pointers

From: Inochi Amaoto

Date: Tue Nov 24 2026 - 23:37:34 EST


Add NULL and error pointer check to the phy_put(), so it can ignore
any bad and empty pointer, this will simplify the release handler
of the bulk data API.

Signed-off-by: Inochi Amaoto <inochiama@xxxxxxxxx>
---
drivers/phy/phy-core.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index efbd7e139dce..5004d28b167a 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -780,6 +780,9 @@ EXPORT_SYMBOL_GPL(of_phy_put);
*/
void phy_put(struct device *dev, struct phy *phy)
{
+ if (IS_ERR_OR_NULL(phy))
+ return;
+
device_link_remove(dev, &phy->dev);
of_phy_put(phy);
}
--
2.56.1