summaryrefslogtreecommitdiffstats
path: root/drivers/soc
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2019-08-16 18:21:51 -0400
committerKrzysztof Kozlowski <krzk@kernel.org>2019-08-19 13:06:14 -0400
commit3636e82135ce5ade87c238e61a315df23dbcd4d6 (patch)
treef39ab2413cb8ba8065533dc36b71345fbe17b717 /drivers/soc
parent40d8aff614f71ab3cab20785b4f213e3802d4e87 (diff)
soc: samsung: chipid: Fix memory leak in error path
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> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Diffstat (limited to 'drivers/soc')
-rw-r--r--drivers/soc/samsung/exynos-chipid.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/soc/samsung/exynos-chipid.c b/drivers/soc/samsung/exynos-chipid.c
index 006a95feb618..75b6b880d9ef 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)
81 soc_dev_attr->soc_id = product_id_to_soc_id(product_id); 81 soc_dev_attr->soc_id = product_id_to_soc_id(product_id);
82 if (!soc_dev_attr->soc_id) { 82 if (!soc_dev_attr->soc_id) {
83 pr_err("Unknown SoC\n"); 83 pr_err("Unknown SoC\n");
84 return -ENODEV; 84 ret = -ENODEV;
85 goto err;
85 } 86 }
86 87
87 /* please note that the actual registration will be deferred */ 88 /* please note that the actual registration will be deferred */
88 soc_dev = soc_device_register(soc_dev_attr); 89 soc_dev = soc_device_register(soc_dev_attr);
89 if (IS_ERR(soc_dev)) { 90 if (IS_ERR(soc_dev)) {
90 kfree(soc_dev_attr->revision); 91 ret = PTR_ERR(soc_dev);
91 kfree(soc_dev_attr); 92 goto err;
92 return PTR_ERR(soc_dev);
93 } 93 }
94 94
95 /* it is too early to use dev_info() here (soc_dev is NULL) */ 95 /* it is too early to use dev_info() here (soc_dev is NULL) */
@@ -97,5 +97,11 @@ int __init exynos_chipid_early_init(void)
97 soc_dev_attr->soc_id, product_id, revision); 97 soc_dev_attr->soc_id, product_id, revision);
98 98
99 return 0; 99 return 0;
100
101err:
102 kfree(soc_dev_attr->revision);
103 kfree(soc_dev_attr);
104 return ret;
100} 105}
106
101early_initcall(exynos_chipid_early_init); 107early_initcall(exynos_chipid_early_init);