Convert to using devm_kstrdup_const() so as to simplify cleanup during
error handling.
Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
drivers/pmdomain/samsung/exynos-pm-domains.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/pmdomain/samsung/exynos-pm-domains.c b/drivers/pmdomain/samsung/exynos-pm-domains.c
index 5d478bb37ad68afc7aed7c6ae19b5fefc94a9035..f53e1bd2479807988f969774b4b7b4c5739c1aba 100644
--- a/drivers/pmdomain/samsung/exynos-pm-domains.c
+++ b/drivers/pmdomain/samsung/exynos-pm-domains.c
@@ -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;
--
2.51.0.618.g983fd99d29-goog
On 07/10/2025 01:43, André Draszik wrote: > Convert to using devm_kstrdup_const() so as to simplify cleanup during > error handling. This is either a fix (then describe the fixed issue and add Fixed tag) or you change the logic, not only simplify. Previously on of_genpd_add_provider_simple() the memory was not kfree_const. Now it will be. Best regards, Krzysztof
On Thu, 2025-10-09 at 09:13 +0900, Krzysztof Kozlowski wrote: > On 07/10/2025 01:43, André Draszik wrote: > > Convert to using devm_kstrdup_const() so as to simplify cleanup during > > error handling. > > > This is either a fix (then describe the fixed issue and add Fixed tag) > or you change the logic, not only simplify. > > Previously on of_genpd_add_provider_simple() the memory was not > kfree_const. Now it will be. Indeed it's a fix after all - While the driver doesn't allow unbind, I added this patch due to the followup patches that add potential error returns during probe, but somehow missed an already-existing error return after this call. Thanks Krzysztof!
On Thu, 2025-10-09 at 14:31 +0100, André Draszik wrote: > On Thu, 2025-10-09 at 09:13 +0900, Krzysztof Kozlowski wrote: > > On 07/10/2025 01:43, André Draszik wrote: > > > Convert to using devm_kstrdup_const() so as to simplify cleanup during > > > error handling. > > > > > > This is either a fix (then describe the fixed issue and add Fixed tag) > > or you change the logic, not only simplify. > > > > Previously on of_genpd_add_provider_simple() the memory was not > > kfree_const. Now it will be. > > Indeed it's a fix after all - While the driver doesn't allow unbind, Thinking more about it - at this stage, this patch is not a fix. The driver can not unbind, hence there is no leak to be plugged, hence no fix. > I added this patch due to the followup patches that add potential error > returns during probe, since it makes the error paths in those follow-up patches simpler > but somehow missed an already-existing error > return after this call. Ignore this last part. I forgot that I simplified this error path in this patch myself :-) So, I'm not sure how to rephrase, tbh. Cheers, A
On 09/10/2025 23:00, André Draszik wrote: > On Thu, 2025-10-09 at 14:31 +0100, André Draszik wrote: >> On Thu, 2025-10-09 at 09:13 +0900, Krzysztof Kozlowski wrote: >>> On 07/10/2025 01:43, André Draszik wrote: >>>> Convert to using devm_kstrdup_const() so as to simplify cleanup during >>>> error handling. >>> >>> >>> This is either a fix (then describe the fixed issue and add Fixed tag) >>> or you change the logic, not only simplify. >>> >>> Previously on of_genpd_add_provider_simple() the memory was not >>> kfree_const. Now it will be. >> >> Indeed it's a fix after all - While the driver doesn't allow unbind, > > Thinking more about it - at this stage, this patch is not a fix. The driver > can not unbind, hence there is no leak to be plugged, hence no fix. It is about error paths. Driver can fail binding. Best regards, Krzysztof
On Fri, 2025-10-10 at 02:35 +0200, Krzysztof Kozlowski wrote: > On 09/10/2025 23:00, André Draszik wrote: > > On Thu, 2025-10-09 at 14:31 +0100, André Draszik wrote: > > > On Thu, 2025-10-09 at 09:13 +0900, Krzysztof Kozlowski wrote: > > > > On 07/10/2025 01:43, André Draszik wrote: > > > > > Convert to using devm_kstrdup_const() so as to simplify cleanup during > > > > > error handling. > > > > > > > > > > > > This is either a fix (then describe the fixed issue and add Fixed tag) > > > > or you change the logic, not only simplify. > > > > > > > > Previously on of_genpd_add_provider_simple() the memory was not > > > > kfree_const. Now it will be. > > > > > > Indeed it's a fix after all - While the driver doesn't allow unbind, > > > > Thinking more about it - at this stage, this patch is not a fix. The driver > > can not unbind, hence there is no leak to be plugged, hence no fix. > > It is about error paths. Driver can fail binding. Thank you Krzysztof for your patience. Yes, I had overlooked that of_genpd_add_provider_simple() itself can fail. Sorry for the noise. Cheers, Andre'
On Mon, 6 Oct 2025 at 17:43, André Draszik <andre.draszik@linaro.org> wrote: > > Convert to using devm_kstrdup_const() so as to simplify cleanup during > error handling. > > Signed-off-by: André Draszik <andre.draszik@linaro.org> > --- Reviewed-by: Peter Griffin <peter.griffin@linaro.org>
© 2016 - 2025 Red Hat, Inc.