[PATCH] mux: mmio: fix regmap leak on probe failure

Johan Hovold posted 1 patch 4 days, 7 hours ago
drivers/mux/mmio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] mux: mmio: fix regmap leak on probe failure
Posted by Johan Hovold 4 days, 7 hours 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: 61de83fd8256 ("mux: mmio: Do not use syscon helper to build regmap")
Cc: stable@vger.kernel.org	# 6.16
Cc: Andrew Davis <afd@ti.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/mux/mmio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mux/mmio.c b/drivers/mux/mmio.c
index 9993ce38a818..5b0171d19d43 100644
--- a/drivers/mux/mmio.c
+++ b/drivers/mux/mmio.c
@@ -58,7 +58,7 @@ static int mux_mmio_probe(struct platform_device *pdev)
 		if (IS_ERR(base))
 			regmap = ERR_PTR(-ENODEV);
 		else
-			regmap = regmap_init_mmio(dev, base, &mux_mmio_regmap_cfg);
+			regmap = devm_regmap_init_mmio(dev, base, &mux_mmio_regmap_cfg);
 		/* Fallback to checking the parent node on "real" errors. */
 		if (IS_ERR(regmap) && regmap != ERR_PTR(-EPROBE_DEFER)) {
 			regmap = dev_get_regmap(dev->parent, NULL);
-- 
2.51.2
Re: [PATCH] mux: mmio: fix regmap leak on probe failure
Posted by Andrew Davis 3 hours ago
On 11/27/25 7:47 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: 61de83fd8256 ("mux: mmio: Do not use syscon helper to build regmap")
> Cc: stable@vger.kernel.org	# 6.16
> Cc: Andrew Davis <afd@ti.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---

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

>   drivers/mux/mmio.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mux/mmio.c b/drivers/mux/mmio.c
> index 9993ce38a818..5b0171d19d43 100644
> --- a/drivers/mux/mmio.c
> +++ b/drivers/mux/mmio.c
> @@ -58,7 +58,7 @@ static int mux_mmio_probe(struct platform_device *pdev)
>   		if (IS_ERR(base))
>   			regmap = ERR_PTR(-ENODEV);
>   		else
> -			regmap = regmap_init_mmio(dev, base, &mux_mmio_regmap_cfg);
> +			regmap = devm_regmap_init_mmio(dev, base, &mux_mmio_regmap_cfg);
>   		/* Fallback to checking the parent node on "real" errors. */
>   		if (IS_ERR(regmap) && regmap != ERR_PTR(-EPROBE_DEFER)) {
>   			regmap = dev_get_regmap(dev->parent, NULL);