Skip to contentSkip to conversation

mfd: exynos-lpass: Fix some error handling paths

PATCH Applied Christophe JAILLET 3 participants 6 messages Apr 21, 2025 – May 1, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover mfd: exynos-lpass: Fix some error handling paths

This serie fixes several issues related to error handling paths in drivers/mfd/exynos-lpass.c.

I've split it in 3 patches to ease review, but it could be merge in only 1 patch if preferred.

Patch 1: Fix a leak in the error handling path of the probe. It should be straighforward. This patch is already R-b.

Patch 2: Slighly unsure of the order of the code. In the probe, we enable pm, then lpass, so should we disable lpass, then pm? This patch is already R-b.

Patch 3: Fix a leak in the error handling path of the probe. It should be straighforward. This replaces patch 3 and 4 of the v1.

All these patches are compile tested only.

Christophe JAILLET (3):
mfd: exynos-lpass: Fix an error handling path in exynos_lpass_probe()
mfd: exynos-lpass: Avoid calling exynos_lpass_disable() twice in
exynos_lpass_remove()
mfd: exynos-lpass: Fix another error handling path in
exynos_lpass_probe()

 drivers/mfd/exynos-lpass.c | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)
Signature · 1 line
2.49.0
#1 lore raw

PATCH v2 1/3 mfd: exynos-lpass: Fix an error handling path in exynos_lpass_probe()

If an error occurs after a successful regmap_init_mmio(), regmap_exit() should be called as already done in the .remove() function.

Switch to devm_regmap_init_mmio() to avoid the leak and simplify the .remove() function.

Fixes c414df12bdf7 ("mfd: exynos-lpass: Add missing remove() function")

---
Compile tested only.

Changes in v2:
- Add R-b tag
- Change the commit ID in Fixes

v1: https://lore.kernel.org/all/d125cbc479f1fa838ed0ff25f0e11d25f382e9d4.1743231856.git.christophe.jaillet@wanadoo.fr/

---
 drivers/mfd/exynos-lpass.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/mfd/exynos-lpass.c +2 -3
index 6a585173230b..6b95927e99be 100644
@@ -122,8 +122,8 @@ static int exynos_lpass_probe(struct platform_device *pdev)
 	if (IS_ERR(lpass->sfr0_clk))
 		return PTR_ERR(lpass->sfr0_clk);
 
-	lpass->top = regmap_init_mmio(dev, base_top,
-					&exynos_lpass_reg_conf);
+	lpass->top = devm_regmap_init_mmio(dev, base_top,
+					   &exynos_lpass_reg_conf);
 	if (IS_ERR(lpass->top)) {
 		dev_err(dev, "LPASS top regmap initialization failed\n");
 		return PTR_ERR(lpass->top);
@@ -145,7 +145,6 @@ static void exynos_lpass_remove(struct platform_device *pdev)
 	pm_runtime_disable(&pdev->dev);
 	if (!pm_runtime_status_suspended(&pdev->dev))
 		exynos_lpass_disable(lpass);
-	regmap_exit(lpass->top);
 }
 
 static int __maybe_unused exynos_lpass_suspend(struct device *dev)
Signature · 1 line
2.49.0
#2 lore raw

PATCH v2 2/3 mfd: exynos-lpass: Avoid calling exynos_lpass_disable() twice in exynos_lpass_remove()

In reply to Christophe JAILLET

exynos_lpass_disable() is called twice in the remove function. Remove one of these calls.

Fixes 90f447170c6f ("mfd: exynos-lpass: Add runtime PM support")

---
Compile tested only.

Changes in v2:
- Add R-b tag

v1: https://lore.kernel.org/all/ee6241d024c4cb68622dde9d65d8712016f4205e.1743231856.git.christophe.jaillet@wanadoo.fr/

---
 drivers/mfd/exynos-lpass.c | 1 -
 1 file changed, 1 deletion(-)
drivers/mfd/exynos-lpass.c +0 -1
index 6b95927e99be..a2785ceea8bf 100644
@@ -141,7 +141,6 @@ static void exynos_lpass_remove(struct platform_device *pdev)
 {
 	struct exynos_lpass *lpass = platform_get_drvdata(pdev);
 
-	exynos_lpass_disable(lpass);
 	pm_runtime_disable(&pdev->dev);
 	if (!pm_runtime_status_suspended(&pdev->dev))
 		exynos_lpass_disable(lpass);
Signature · 1 line
2.49.0
#3 lore raw

PATCH v2 3/3 mfd: exynos-lpass: Fix another error handling path in exynos_lpass_probe()

In reply to Christophe JAILLET

If devm_of_platform_populate() fails, some clean-up needs to be done, as already done in the remove function.

Add a new devm_add_action_or_reset() to fix the leak in the probe and remove the need of a remove function.

Fixes c695abab2429 ("mfd: Add Samsung Exynos Low Power Audio Subsystem driver")

---
Compile tested only.

Changes in v2:
- Use a new devm_add_action_or_reset() to fix the leak in the probe and remove the need of a remove function.
- Update the commit description accordingly

v1: https://lore.kernel.org/all/d224865a16b50498279b044a819e1e187d01bb28.1743231856.git.christophe.jaillet@wanadoo.fr/

---
 drivers/mfd/exynos-lpass.c | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)
drivers/mfd/exynos-lpass.c +15 -10
index a2785ceea8bf..44797001a432 100644
@@ -104,11 +104,22 @@ static const struct regmap_config exynos_lpass_reg_conf = {
 	.fast_io	= true,
 };
 
+static void exynos_lpass_disable_lpass(void *data)
+{
+	struct platform_device *pdev = data;
+	struct exynos_lpass *lpass = platform_get_drvdata(pdev);
+
+	pm_runtime_disable(&pdev->dev);
+	if (!pm_runtime_status_suspended(&pdev->dev))
+		exynos_lpass_disable(lpass);
+}
+
 static int exynos_lpass_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct exynos_lpass *lpass;
 	void __iomem *base_top;
+	int ret;
 
 	lpass = devm_kzalloc(dev, sizeof(*lpass), GFP_KERNEL);
 	if (!lpass)
@@ -134,16 +145,11 @@ static int exynos_lpass_probe(struct platform_device *pdev)
 	pm_runtime_enable(dev);
 	exynos_lpass_enable(lpass);
 
-	return devm_of_platform_populate(dev);
-}
-
-static void exynos_lpass_remove(struct platform_device *pdev)
-{
-	struct exynos_lpass *lpass = platform_get_drvdata(pdev);
+	ret = devm_add_action_or_reset(dev, exynos_lpass_disable_lpass, pdev);
+	if (ret)
+		return ret;
 
-	pm_runtime_disable(&pdev->dev);
-	if (!pm_runtime_status_suspended(&pdev->dev))
-		exynos_lpass_disable(lpass);
+	return devm_of_platform_populate(dev);
 }
 
 static int __maybe_unused exynos_lpass_suspend(struct device *dev)
@@ -183,7 +189,6 @@ static struct platform_driver exynos_lpass_driver = {
 		.of_match_table	= exynos_lpass_of_match,
 	},
 	.probe	= exynos_lpass_probe,
-	.remove	= exynos_lpass_remove,
 };
 module_platform_driver(exynos_lpass_driver);
 
Signature · 1 line
2.49.0
maintainer Reviewed-by on v2 3/3
#4 lore raw

Re: [PATCH v2 3/3] mfd: exynos-lpass: Fix another error handling path in exynos_lpass_probe()

Quoted 8 lines · Christophe JAILLET

If devm_of_platform_populate() fails, some clean-up needs to be done, as already done in the remove function.

Add a new devm_add_action_or_reset() to fix the leak in the probe and remove the need of a remove function.

Fixes c695abab2429 ("mfd: Add Samsung Exynos Low Power Audio Subsystem driver")
Quoted 7 lines

---
Compile tested only.

Changes in v2:
- Use a new devm_add_action_or_reset() to fix the leak in the probe and remove the need of a remove function.
- Update the commit description accordingly

Best regards,
Krzysztof

maintainer Applied
#5 lore raw
In reply to Christophe JAILLET
Quoted 10 lines · Christophe JAILLET

This serie fixes several issues related to error handling paths in drivers/mfd/exynos-lpass.c.

I've split it in 3 patches to ease review, but it could be merge in only 1 patch if preferred.

Patch 1: Fix a leak in the error handling path of the probe. It should be straighforward. This patch is already R-b.

[...]

Applied, thanks!

[1/3] mfd: exynos-lpass: Fix an error handling path in exynos_lpass_probe()

      commit: 8cc4952d1e8618eff474dc7154c6537db88178df
[2/3] mfd: exynos-lpass: Avoid calling exynos_lpass_disable() twice in exynos_lpass_remove()
      commit: cb931849ec1e71900eb54d0a377ae30e0bcfcffa
[3/3] mfd: exynos-lpass: Fix another error handling path in exynos_lpass_probe()
      commit: f408e20757afa3d8c719a8a804cd2c83262514dd

--
Lee Jones [李琼斯]