[PATCH] [ARM] tcm: Add error handling for gen_pool_create in setup_tcm_pool

From: Haoran Liu
Date: Wed Nov 29 2023 - 01:16:40 EST


The new code checks the return value of gen_pool_create, and if
it indicates an error, the setup process is aborted, and an
appropriate error code is returned. This ensures that the TCM pool
setup does not silently fail.

Signed-off-by: Haoran Liu <liuhaoran14@xxxxxxx>
---
arch/arm/kernel/tcm.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/arch/arm/kernel/tcm.c b/arch/arm/kernel/tcm.c
index f59927bcfbce..df25d310abc3 100644
--- a/arch/arm/kernel/tcm.c
+++ b/arch/arm/kernel/tcm.c
@@ -393,6 +393,10 @@ static int __init setup_tcm_pool(void)
* line alignments does not matter in TCM!
*/
tcm_pool = gen_pool_create(2, -1);
+ if (!tcm_pool) {
+ pr_err("Failed to create TCM memory pool\n");
+ return -ENOMEM;
+ }

pr_debug("Setting up TCM memory pool\n");

--
2.17.1