[PATCH] phy: ti: gmii-sel: fix regmap leak on probe failure

Johan Hovold posted 1 patch 2 months, 1 week ago
drivers/phy/ti/phy-gmii-sel.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] phy: ti: gmii-sel: fix regmap leak on probe failure
Posted by Johan Hovold 2 months, 1 week ago
The mmio regmap that may be allocated during probe is never freed.

Switch to using the device managed allocator so that the regmap is
released on probe failures (e.g. probe deferral) and on driver unbind.

Fixes: 5ab90f40121a ("phy: ti: gmii-sel: Do not use syscon helper to build regmap")
Cc: stable@vger.kernel.org	# 6.14
Cc: Andrew Davis <afd@ti.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/phy/ti/phy-gmii-sel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/phy/ti/phy-gmii-sel.c b/drivers/phy/ti/phy-gmii-sel.c
index 50adabb867cb..26209a89703a 100644
--- a/drivers/phy/ti/phy-gmii-sel.c
+++ b/drivers/phy/ti/phy-gmii-sel.c
@@ -512,7 +512,7 @@ static int phy_gmii_sel_probe(struct platform_device *pdev)
 			return dev_err_probe(dev, PTR_ERR(base),
 					     "failed to get base memory resource\n");
 
-		priv->regmap = regmap_init_mmio(dev, base, &phy_gmii_sel_regmap_cfg);
+		priv->regmap = devm_regmap_init_mmio(dev, base, &phy_gmii_sel_regmap_cfg);
 		if (IS_ERR(priv->regmap))
 			return dev_err_probe(dev, PTR_ERR(priv->regmap),
 					     "Failed to get syscon\n");
-- 
2.51.2
Re: [PATCH] phy: ti: gmii-sel: fix regmap leak on probe failure
Posted by Vinod Koul 1 month, 2 weeks ago
On Thu, 27 Nov 2025 14:48:34 +0100, Johan Hovold wrote:
> The mmio regmap that may be allocated during probe is never freed.
> 
> Switch to using the device managed allocator so that the regmap is
> released on probe failures (e.g. probe deferral) and on driver unbind.
> 
> 

Applied, thanks!

[1/1] phy: ti: gmii-sel: fix regmap leak on probe failure
      commit: 4914d67da947031d6f645c81c74f7879e0844d5d

Best regards,
-- 
~Vinod
Re: [PATCH] phy: ti: gmii-sel: fix regmap leak on probe failure
Posted by Andrew Davis 2 months, 1 week ago
On 11/27/25 7:48 AM, Johan Hovold wrote:
> The mmio regmap that may be allocated during probe is never freed.
> 
> Switch to using the device managed allocator so that the regmap is
> released on probe failures (e.g. probe deferral) and on driver unbind.
> 
> Fixes: 5ab90f40121a ("phy: ti: gmii-sel: Do not use syscon helper to build regmap")
> Cc: stable@vger.kernel.org	# 6.14
> Cc: Andrew Davis <afd@ti.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---

Acked-by: Andrew Davis <afd@ti.com>

>   drivers/phy/ti/phy-gmii-sel.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/phy/ti/phy-gmii-sel.c b/drivers/phy/ti/phy-gmii-sel.c
> index 50adabb867cb..26209a89703a 100644
> --- a/drivers/phy/ti/phy-gmii-sel.c
> +++ b/drivers/phy/ti/phy-gmii-sel.c
> @@ -512,7 +512,7 @@ static int phy_gmii_sel_probe(struct platform_device *pdev)
>   			return dev_err_probe(dev, PTR_ERR(base),
>   					     "failed to get base memory resource\n");
>   
> -		priv->regmap = regmap_init_mmio(dev, base, &phy_gmii_sel_regmap_cfg);
> +		priv->regmap = devm_regmap_init_mmio(dev, base, &phy_gmii_sel_regmap_cfg);
>   		if (IS_ERR(priv->regmap))
>   			return dev_err_probe(dev, PTR_ERR(priv->regmap),
>   					     "Failed to get syscon\n");