diff options
author | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2015-12-29 11:32:20 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-02-08 04:11:51 (GMT) |
commit | e5b3ecebdf153509118ab1de6b3707a9889c300d (patch) | |
tree | 41e1a724212774e3f9eb2ee0fc0e655c91fcadbd | |
parent | c5af6be354e3e4c10fc54d48f5a4fb6744ea293a (diff) | |
download | linux-e5b3ecebdf153509118ab1de6b3707a9889c300d.tar.xz |
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>
-rw-r--r-- | drivers/staging/mt29f_spinand/mt29f_spinand.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/staging/mt29f_spinand/mt29f_spinand.c b/drivers/staging/mt29f_spinand/mt29f_spinand.c index 197d112..983371b 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++) |