Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: c09a3e6c97f0 ("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>

authored by

André Draszik and committed by
Ulf Hansson
90c82941 211ddde0

+5 -6
+5 -6
drivers/pmdomain/samsung/exynos-pm-domains.c
··· 92 92 { }, 93 93 }; 94 94 95 - static const char *exynos_get_domain_name(struct device_node *node) 95 + static const char *exynos_get_domain_name(struct device *dev, 96 + struct device_node *node) 96 97 { 97 98 const char *name; 98 99 99 100 if (of_property_read_string(node, "label", &name) < 0) 100 101 name = kbasename(node->full_name); 101 - return kstrdup_const(name, GFP_KERNEL); 102 + return devm_kstrdup_const(dev, name, GFP_KERNEL); 102 103 } 103 104 104 105 static int exynos_pd_probe(struct platform_device *pdev) ··· 116 115 if (!pd) 117 116 return -ENOMEM; 118 117 119 - pd->pd.name = exynos_get_domain_name(np); 118 + pd->pd.name = exynos_get_domain_name(dev, np); 120 119 if (!pd->pd.name) 121 120 return -ENOMEM; 122 121 123 122 pd->base = of_iomap(np, 0); 124 - if (!pd->base) { 125 - kfree_const(pd->pd.name); 123 + if (!pd->base) 126 124 return -ENODEV; 127 - } 128 125 129 126 pd->pd.power_off = exynos_pd_power_off; 130 127 pd->pd.power_on = exynos_pd_power_on;