[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20251230065859.1046756-1-zilin@seu.edu.cn>
Date: Tue, 30 Dec 2025 06:58:59 +0000
From: Zilin Guan <zilin@....edu.cn>
To: robh@...nel.org
Cc: saravanak@...gle.com,
devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org,
Zilin Guan <zilin@....edu.cn>,
Jianhao Xu <jianhao.xu@....edu.cn>
Subject: [PATCH] of: unittest: Fix memory leak in unittest_data_add()
In unittest_data_add(), if of_resolve_phandles() fails, the allocated
unittest_data is not freed, leading to a memory leak.
Fix this by freeing unittest_data in the error handling path before
returning.
Fixes: 2eb46da2a760 ("of/selftest: Use the resolver to fixup phandles")
Co-developed-by: Jianhao Xu <jianhao.xu@....edu.cn>
Signed-off-by: Jianhao Xu <jianhao.xu@....edu.cn>
Signed-off-by: Zilin Guan <zilin@....edu.cn>
---
drivers/of/unittest.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 388e9ec2cccf..8622a8ac1814 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -2031,6 +2031,7 @@ static int __init unittest_data_add(void)
rc = of_resolve_phandles(unittest_data_node);
if (rc) {
pr_err("%s: Failed to resolve phandles (rc=%i)\n", __func__, rc);
+ kfree(unittest_data);
rc = -EINVAL;
goto unlock;
}
--
2.34.1
Powered by blists - more mailing lists