Linux MIPS Architecture development
 help / color / mirror / Atom feed
* [PATCH 04/10] phy: eyeq5-eth: Set .owner = THIS_MODULE
       [not found] <20261130225428.99361-1-irogers@google.com>
@ 2026-11-30 22:54 ` Ian Rogers
  2026-12-01 10:25   ` Théo Lebrun
  0 siblings, 1 reply; 2+ messages in thread
From: Ian Rogers @ 2026-11-30 22:54 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Neil Armstrong, Manivannan Sadhasivam, Nathan Chancellor,
	linux-phy, llvm, linux-kernel, Ian Rogers, Vladimir Kondratiev,
	Benoît Monin, Gregory CLEMENT, Théo Lebrun,
	Vladimir Oltean, Luca Ceresoli, linux-mips

phy_get() and of_phy_get() call try_module_get(phy->ops->owner) to pin
the PHY provider module while the PHY is in use, and of_phy_put() calls
module_put(phy->ops->owner). Because phy->ops is const struct phy_ops *,
phy_create() cannot populate ops->owner at runtime, and
try_module_get(NULL) returns true without incrementing the module
reference count.

Set .owner = THIS_MODULE in eq5_phy_ops, found with Clang's
require_explicit_initialization attribute.

Fixes: b6e33443876d ("phy: Add driver for EyeQ5 Ethernet PHY wrapper")
Signed-off-by: Ian Rogers <irogers@google.com>
---
 drivers/phy/phy-eyeq5-eth.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/phy/phy-eyeq5-eth.c b/drivers/phy/phy-eyeq5-eth.c
index fae147268f5f..69c428a867c8 100644
--- a/drivers/phy/phy-eyeq5-eth.c
+++ b/drivers/phy/phy-eyeq5-eth.c
@@ -182,6 +182,7 @@ static const struct phy_ops eq5_phy_ops = {
 	.power_off	= eq5_phy_power_off,
 	.set_mode	= eq5_phy_set_mode,
 	.validate	= eq5_phy_validate,
+	.owner		= THIS_MODULE,
 };
 
 static struct phy *eq5_phy_xlate(struct device *dev,
-- 
2.56.1.839.g22a8290db9-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 04/10] phy: eyeq5-eth: Set .owner = THIS_MODULE
  2026-11-30 22:54 ` [PATCH 04/10] phy: eyeq5-eth: Set .owner = THIS_MODULE Ian Rogers
@ 2026-12-01 10:25   ` Théo Lebrun
  0 siblings, 0 replies; 2+ messages in thread
From: Théo Lebrun @ 2026-12-01 10:25 UTC (permalink / raw)
  To: Ian Rogers, Vinod Koul
  Cc: Neil Armstrong, Manivannan Sadhasivam, Nathan Chancellor,
	linux-phy, llvm, linux-kernel, Vladimir Kondratiev,
	Benoît Monin, Gregory CLEMENT, Vladimir Oltean,
	Luca Ceresoli, linux-mips

Hello Ian,

On Mon Nov 30, 2026 at 11:54 PM CET, Ian Rogers wrote:
> phy_get() and of_phy_get() call try_module_get(phy->ops->owner) to pin
> the PHY provider module while the PHY is in use, and of_phy_put() calls
> module_put(phy->ops->owner). Because phy->ops is const struct phy_ops *,
> phy_create() cannot populate ops->owner at runtime, and
> try_module_get(NULL) returns true without incrementing the module
> reference count.
>
> Set .owner = THIS_MODULE in eq5_phy_ops, found with Clang's
> require_explicit_initialization attribute.
>
> Fixes: b6e33443876d ("phy: Add driver for EyeQ5 Ethernet PHY wrapper")
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
>  drivers/phy/phy-eyeq5-eth.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/phy/phy-eyeq5-eth.c b/drivers/phy/phy-eyeq5-eth.c
> index fae147268f5f..69c428a867c8 100644
> --- a/drivers/phy/phy-eyeq5-eth.c
> +++ b/drivers/phy/phy-eyeq5-eth.c
> @@ -182,6 +182,7 @@ static const struct phy_ops eq5_phy_ops = {
>  	.power_off	= eq5_phy_power_off,
>  	.set_mode	= eq5_phy_set_mode,
>  	.validate	= eq5_phy_validate,
> +	.owner		= THIS_MODULE,
>  };
>  
>  static struct phy *eq5_phy_xlate(struct device *dev,

Reviewed-by: Théo Lebrun <theo.lebrun@bootlin.com>

Thanks,

--
Théo Lebrun, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-01 10:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20261130225428.99361-1-irogers@google.com>
2026-11-30 22:54 ` [PATCH 04/10] phy: eyeq5-eth: Set .owner = THIS_MODULE Ian Rogers
2026-12-01 10:25   ` Théo Lebrun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox