Skip to content

Commit f41cc37

Browse files
tititiou36lag-linaro
authored andcommitted
mfd: exynos-lpass: Fix another error handling path in exynos_lpass_probe()
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: c695aba ("mfd: Add Samsung Exynos Low Power Audio Subsystem driver") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/69471e839efc0249a504492a8de3497fcdb6a009.1745247209.git.christophe.jaillet@wanadoo.fr Signed-off-by: Lee Jones <lee@kernel.org>
1 parent b70b845 commit f41cc37

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

drivers/mfd/exynos-lpass.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,22 @@ static const struct regmap_config exynos_lpass_reg_conf = {
104104
.fast_io = true,
105105
};
106106

107+
static void exynos_lpass_disable_lpass(void *data)
108+
{
109+
struct platform_device *pdev = data;
110+
struct exynos_lpass *lpass = platform_get_drvdata(pdev);
111+
112+
pm_runtime_disable(&pdev->dev);
113+
if (!pm_runtime_status_suspended(&pdev->dev))
114+
exynos_lpass_disable(lpass);
115+
}
116+
107117
static int exynos_lpass_probe(struct platform_device *pdev)
108118
{
109119
struct device *dev = &pdev->dev;
110120
struct exynos_lpass *lpass;
111121
void __iomem *base_top;
122+
int ret;
112123

113124
lpass = devm_kzalloc(dev, sizeof(*lpass), GFP_KERNEL);
114125
if (!lpass)
@@ -134,16 +145,11 @@ static int exynos_lpass_probe(struct platform_device *pdev)
134145
pm_runtime_enable(dev);
135146
exynos_lpass_enable(lpass);
136147

137-
return devm_of_platform_populate(dev);
138-
}
139-
140-
static void exynos_lpass_remove(struct platform_device *pdev)
141-
{
142-
struct exynos_lpass *lpass = platform_get_drvdata(pdev);
148+
ret = devm_add_action_or_reset(dev, exynos_lpass_disable_lpass, pdev);
149+
if (ret)
150+
return ret;
143151

144-
pm_runtime_disable(&pdev->dev);
145-
if (!pm_runtime_status_suspended(&pdev->dev))
146-
exynos_lpass_disable(lpass);
152+
return devm_of_platform_populate(dev);
147153
}
148154

149155
static int __maybe_unused exynos_lpass_suspend(struct device *dev)
@@ -183,7 +189,6 @@ static struct platform_driver exynos_lpass_driver = {
183189
.of_match_table = exynos_lpass_of_match,
184190
},
185191
.probe = exynos_lpass_probe,
186-
.remove = exynos_lpass_remove,
187192
};
188193
module_platform_driver(exynos_lpass_driver);
189194

0 commit comments

Comments
 (0)