nand: vybrid: Use calloc() instead of malloc() to allocate struct nfc
authorLukasz Majewski <lukma@denx.de>
Mon, 3 Dec 2018 09:20:47 +0000 (10:20 +0100)
committerStefano Babic <sbabic@denx.de>
Tue, 1 Jan 2019 13:12:18 +0000 (14:12 +0100)
commit254409dbe836633b079968c0e7686ecd09b45dc7
tree3eb0f5ab44a7961886b74fa8be3dcd10263e673c
parentf026c1d9ef1cd20e966f57f53de25cb124ac2413
nand: vybrid: Use calloc() instead of malloc() to allocate struct nfc

Without this change it is possible that Vybrid's NFC driver malloc() call
will obtain some memory used (and correctly free'd) by some previous
driver (in this case pinctrl for Vybrid).

As a result some fields of struct nfc - in out case mtd->_get_device - are
"pre initialized" with some random values.

On the latter stage of booting, when e.g. somebody calls 'mtdparts default'
the "data abort" is observed when __get_mtd_device() function is called.

The mtd->_get_device pointer is not NULL and wrong value is referenced.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Stefan Agner <stefan.agner@toradex.com>
drivers/mtd/nand/raw/vf610_nfc.c