mtd: inftl: Fix potential table leaks on mount failure
PATCH 1/1 mtd: inftl: Fix potential table leaks on mount failure
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.
--- drivers/mtd/inftlmount.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/mtd/inftlmount.c +4 -1
@@ -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
Quoted 8 lines · Guangshuo Li
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.
[...]
Applied to mtd/next, thanks!
[1/1] mtd: inftl: Fix potential table leaks on mount failure
commit: dd4e68b5061efb56eea093b6a9b7a6da49efda07
Patche(s) should be available on mtd/linux.git and will be part of the next PR (provided that no robot complains by then).
Kind regards,
Miquèl