[PATCH] mtd: inftl: Fix potential table leaks on mount failure

From: Guangshuo Li

Date: Wed Nov 11 2026 - 07:32:22 EST


If the temporary ANAC table allocation fails, the unit tables allocated
by find_boot_record() are left behind when the caller frees the INFTL
record. Free both tables before returning the error.

This issue was found by our static analysis tool under development.

Fixes: 8766af935f3f ("[PATCH] check for failed kmalloc in inftlmount.c")
Signed-off-by: Guangshuo Li <liguangshuo@xxxxxxxxxxxxxxx>
---
drivers/mtd/inftlmount.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/inftlmount.c b/drivers/mtd/inftlmount.c
index 87e246a6f488..841ae05bca7b 100644
--- a/drivers/mtd/inftlmount.c
+++ b/drivers/mtd/inftlmount.c
@@ -551,8 +551,11 @@ int INFTL_mount(struct INFTLrecord *s)

/* Temporary buffer to store ANAC numbers. */
ANACtable = kcalloc(s->nb_blocks, sizeof(u8), GFP_KERNEL);
- if (!ANACtable)
+ if (!ANACtable) {
+ kfree(s->PUtable);
+ kfree(s->VUtable);
return -ENOMEM;
+ }

/*
* First pass is to explore each physical unit, and construct the

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4