soc: aspeed: Fix memory leak issue in aspeed_socinfo_init()
Commit Message
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(+)
@@ -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);