mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 01:49:46 +00:00
pmdomain: samsung: plug potential memleak during probe
of_genpd_add_provider_simple() could fail, in which case this code
leaks the domain name, pd->pd.name.
Use devm_kstrdup_const() to plug this leak. As a side-effect, we can
simplify existing error handling.
Fixes: c09a3e6c97 ("soc: samsung: pm_domains: Convert to regular platform driver")
Cc: stable@vger.kernel.org
Reviewed-by: Peter Griffin <peter.griffin@linaro.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: André Draszik <andre.draszik@linaro.org>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
committed by
Ulf Hansson
parent
211ddde082
commit
90c82941ad
@@ -92,13 +92,14 @@ static const struct of_device_id exynos_pm_domain_of_match[] = {
|
||||
{ },
|
||||
};
|
||||
|
||||
static const char *exynos_get_domain_name(struct device_node *node)
|
||||
static const char *exynos_get_domain_name(struct device *dev,
|
||||
struct device_node *node)
|
||||
{
|
||||
const char *name;
|
||||
|
||||
if (of_property_read_string(node, "label", &name) < 0)
|
||||
name = kbasename(node->full_name);
|
||||
return kstrdup_const(name, GFP_KERNEL);
|
||||
return devm_kstrdup_const(dev, name, GFP_KERNEL);
|
||||
}
|
||||
|
||||
static int exynos_pd_probe(struct platform_device *pdev)
|
||||
@@ -115,15 +116,13 @@ static int exynos_pd_probe(struct platform_device *pdev)
|
||||
if (!pd)
|
||||
return -ENOMEM;
|
||||
|
||||
pd->pd.name = exynos_get_domain_name(np);
|
||||
pd->pd.name = exynos_get_domain_name(dev, np);
|
||||
if (!pd->pd.name)
|
||||
return -ENOMEM;
|
||||
|
||||
pd->base = of_iomap(np, 0);
|
||||
if (!pd->base) {
|
||||
kfree_const(pd->pd.name);
|
||||
if (!pd->base)
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
pd->pd.power_off = exynos_pd_power_off;
|
||||
pd->pd.power_on = exynos_pd_power_on;
|
||||
|
||||
Reference in New Issue
Block a user