* [PATCH] mtd: inftl: Fix potential table leaks on mount failure
@ 2026-11-11 12:23 Guangshuo Li
0 siblings, 0 replies; only message in thread
From: Guangshuo Li @ 2026-11-11 12:23 UTC (permalink / raw)
To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra
Cc: linux-mtd, linux-kernel
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@mail.sdu.edu.cn>
---
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-11 12:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-11 12:23 [PATCH] mtd: inftl: Fix potential table leaks on mount failure Guangshuo Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®