[PATCH] staging: mt29f_spinand: fix memory leak while programming pages

From: Jheng-Jhong Wu
Date: Wed Aug 01 2018 - 05:45:07 EST


In spinand_program_page(), it uses devm_kzalloc() to allocate memory to
wbuf dynamically if internal ECC is on, but it doesn't free memory
allocated to wbuf at the end of this function. This leads to a memory leak
issue when internal ECC is on.

Signed-off-by: Jheng-Jhong Wu <goodwater.wu@xxxxxxxxx>
---
drivers/staging/mt29f_spinand/mt29f_spinand.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/staging/mt29f_spinand/mt29f_spinand.c b/drivers/staging/mt29f_spinand/mt29f_spinand.c
index e389009..cf51ca8 100644
--- a/drivers/staging/mt29f_spinand/mt29f_spinand.c
+++ b/drivers/staging/mt29f_spinand/mt29f_spinand.c
@@ -553,6 +553,8 @@ static int spinand_program_page(struct spi_device *spi_nand,
}
enable_hw_ecc = 0;
}
+
+ devm_kfree(&spi_nand->dev, wbuf);
#endif

return 0;
--
2.7.4