staging: mt29f: fix unchecked malloc()

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@elzevir.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Manuel Pégourié-Gonnard 2015-12-29 12:32:20 +01:00 committed by Greg Kroah-Hartman
parent c5af6be354
commit e5b3ecebdf

View file

@ -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++)