lkml.org 
[lkml]   [2022]   [Nov]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] soc: aspeed: Fix memory leak issue in aspeed_socinfo_init()
Date
If soc_device_register() fails, @attrs->machine may have allocated
string, it should be freed before return error, otherwise will cause
memory leak issue, fix it.

Fixes: e0218dca5787 ("soc: aspeed: Add soc info driver")
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
---
drivers/soc/aspeed/aspeed-socinfo.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/soc/aspeed/aspeed-socinfo.c b/drivers/soc/aspeed/aspeed-socinfo.c
index 1ca140356a08..3f759121dc00 100644
--- a/drivers/soc/aspeed/aspeed-socinfo.c
+++ b/drivers/soc/aspeed/aspeed-socinfo.c
@@ -137,6 +137,7 @@ static int __init aspeed_socinfo_init(void)

soc_dev = soc_device_register(attrs);
if (IS_ERR(soc_dev)) {
+ kfree(attrs->machine);
kfree(attrs->soc_id);
kfree(attrs->serial_number);
kfree(attrs);
--
2.17.1
\
 
 \ /
  Last update: 2022-11-23 15:06    [W:0.030 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site