[PATCH 2/4] staging: mt29f: fix unchecked malloc()
Manuel Pégourié-Gonnard
mpg at elzevir.fr
Tue Dec 29 03:32:20 PST 2015
The pointer is unconditionally dereferenced a few lines later, we need to make
sure it isn't NULL.
Signed-off-by: Manuel Pégourié-Gonnard <mpg at elzevir.fr>
---
drivers/staging/mt29f_spinand/mt29f_spinand.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/mt29f_spinand/mt29f_spinand.c b/drivers/staging/mt29f_spinand/mt29f_spinand.c
index dc2b1fc995c2..c4a3236dd566 100644
--- a/drivers/staging/mt29f_spinand/mt29f_spinand.c
+++ b/drivers/staging/mt29f_spinand/mt29f_spinand.c
@@ -483,8 +483,11 @@ static int spinand_program_page(struct spi_device *spi_nand,
#ifdef CONFIG_MTD_SPINAND_ONDIEECC
unsigned int i, j;
- enable_read_hw_ecc = 0;
wbuf = devm_kzalloc(&spi_nand->dev, CACHE_BUF, GFP_KERNEL);
+ if (!wbuf)
+ return -ENOMEM;
+
+ enable_read_hw_ecc = 0;
spinand_read_page(spi_nand, page_id, 0, CACHE_BUF, wbuf);
for (i = offset, j = 0; i < len; i++, j++)
--
2.6.4
More information about the linux-mtd
mailing list