soc: aspeed: socinfo: Add kfree for kstrdup
authorJiasheng Jiang <jiasheng@iscas.ac.cn>
Thu, 10 Aug 2023 12:31:04 +0000 (22:01 +0930)
committerArnd Bergmann <arnd@arndb.de>
Sat, 12 Aug 2023 10:12:58 +0000 (12:12 +0200)
Add kfree() in the later error handling in order to avoid memory leak.

Fixes: e0218dca5787 ("soc: aspeed: Add soc info driver")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Link: https://lore.kernel.org/r/20230707021625.7727-1-jiasheng@iscas.ac.cn
Signed-off-by: Joel Stanley <joel@jms.id.au>
Link: https://lore.kernel.org/r/20230810123104.231167-1-joel@jms.id.au
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
drivers/soc/aspeed/aspeed-socinfo.c

index 1ca140356a084d4c7de9b7331c271e6b7d6355af..3f759121dc00a44a24de23e39540080815cb7c94 100644 (file)
@@ -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);