* [PATCH][next] soc: samsung: exynos-chipid: fix memory leak
@ 2019-08-16 22:21 Colin King
2019-08-19 17:09 ` Krzysztof Kozlowski
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2019-08-16 22:21 UTC (permalink / raw)
To: Pankaj Dubey, Kukjin Kim, Krzysztof Kozlowski, linux-arm-kernel,
linux-samsung-soc
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Currently when the call to product_id_to_soc_id fails there
is a memory leak of soc_dev_attr->revision and soc_dev_attr
on the error return path. Fix this by adding a common error
return path that frees there obects and use this for two
error return paths.
Addresses-Coverity: ("Resource leak")
Fixes: 3253b7b7cd44 ("soc: samsung: Add exynos chipid driver support")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/soc/samsung/exynos-chipid.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/soc/samsung/exynos-chipid.c b/drivers/soc/samsung/exynos-chipid.c
index 006a95feb618..4e194a97c0fa 100644
--- a/drivers/soc/samsung/exynos-chipid.c
+++ b/drivers/soc/samsung/exynos-chipid.c
@@ -81,15 +81,15 @@ int __init exynos_chipid_early_init(void)
soc_dev_attr->soc_id = product_id_to_soc_id(product_id);
if (!soc_dev_attr->soc_id) {
pr_err("Unknown SoC\n");
- return -ENODEV;
+ ret = -ENODEV;
+ goto err;
}
/* please note that the actual registration will be deferred */
soc_dev = soc_device_register(soc_dev_attr);
if (IS_ERR(soc_dev)) {
- kfree(soc_dev_attr->revision);
- kfree(soc_dev_attr);
- return PTR_ERR(soc_dev);
+ ret = PTR_ERR(soc_dev);
+ goto err;
}
/* it is too early to use dev_info() here (soc_dev is NULL) */
@@ -97,5 +97,11 @@ int __init exynos_chipid_early_init(void)
soc_dev_attr->soc_id, product_id, revision);
return 0;
+
+err:
+ kfree(soc_dev_attr->revision);
+ kfree(soc_dev_attr);
+ return ret;
}
+
early_initcall(exynos_chipid_early_init);
--
2.20.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH][next] soc: samsung: exynos-chipid: fix memory leak
2019-08-16 22:21 [PATCH][next] soc: samsung: exynos-chipid: fix memory leak Colin King
@ 2019-08-19 17:09 ` Krzysztof Kozlowski
0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Kozlowski @ 2019-08-19 17:09 UTC (permalink / raw)
To: Colin King
Cc: linux-samsung-soc, Pankaj Dubey, kernel-janitors, linux-kernel,
Kukjin Kim, linux-arm-kernel
On Fri, Aug 16, 2019 at 11:21:51PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently when the call to product_id_to_soc_id fails there
> is a memory leak of soc_dev_attr->revision and soc_dev_attr
> on the error return path. Fix this by adding a common error
> return path that frees there obects and use this for two
> error return paths.
>
> Addresses-Coverity: ("Resource leak")
> Fixes: 3253b7b7cd44 ("soc: samsung: Add exynos chipid driver support")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/soc/samsung/exynos-chipid.c | 14 ++++++++++----
Thanks, applied.
Best regards,
Krzysztof
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-08-19 17:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-16 22:21 [PATCH][next] soc: samsung: exynos-chipid: fix memory leak Colin King
2019-08-19 17:09 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).