mtd: rawnand: meson: add missing ENOMEM check in meson_nfc_read_buf()
authorMartin Blumenstingl <martin.blumenstingl@googlemail.com>
Mon, 18 Mar 2019 20:47:21 +0000 (21:47 +0100)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Thu, 21 Mar 2019 15:48:57 +0000 (16:48 +0100)
kzalloc() can return NULL if memory could not be allocated. Check the
return value of the kzalloc() call in meson_nfc_read_buf() to make it
consistent with other memory allocations within the meson_nand driver.

Fixes: 8fae856c53500a ("mtd: rawnand: meson: add support for Amlogic NAND flash controller")
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Acked-by: Liang Yang <liang.yang@amlogic.com>
Reviewed-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
drivers/mtd/nand/raw/meson_nand.c

index 3e8aa71407b53ca1e1f6d40e2eda5cee1d595eee..a1d8506b61c7136bb9b6e3ba03ff19d8772b8f4a 100644 (file)
@@ -528,6 +528,9 @@ static int meson_nfc_read_buf(struct nand_chip *nand, u8 *buf, int len)
        u8 *info;
 
        info = kzalloc(PER_INFO_BYTE, GFP_KERNEL);
+       if (!info)
+               return -ENOMEM;
+
        ret = meson_nfc_dma_buffer_setup(nand, buf, len, info,
                                         PER_INFO_BYTE, DMA_FROM_DEVICE);
        if (ret)