[PATCH] memstick: ms_block: Fix potential block buffer leak
From: Guangshuo Li
Date: Tue Nov 03 2026 - 21:34:30 EST
msb_init_card() allocates a block buffer, but msb_data_clear() does
not free it. The buffer is leaked on probe failure, removal and
when discarding the temporary card state used during resume.
Free it with the other allocations in msb_data_clear().
This issue was found by our static analysis tool under development.
Fixes: 0ab30494bc4f ("memstick: add support for legacy memorysticks")
Signed-off-by: Guangshuo Li <liguangshuo@xxxxxxxxxxxxxxx>
---
Build-tested the changed object with x86_64 GCC W=1, using defconfig
with the driver dependencies enabled. No hardware/kernel runtime test or full linked-kernel
build.
OpenAI Codex assisted with source review, patch implementation and
commit-message drafting. The submitter has reviewed the changes.
drivers/memstick/core/ms_block.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/memstick/core/ms_block.c b/drivers/memstick/core/ms_block.c
index cd4ff1b79a6d..d62350f9ef5b 100644
--- a/drivers/memstick/core/ms_block.c
+++ b/drivers/memstick/core/ms_block.c
@@ -1953,6 +1953,7 @@ static void msb_data_clear(struct msb_data *msb)
bitmap_free(msb->erased_blocks_bitmap);
kfree(msb->lba_to_pba_table);
kfree(msb->cache);
+ kfree(msb->block_buffer);
msb->card = NULL;
}
base-commit: 05441d697f7f9a927264f4058cbbc6a03dfcac9d