Squash the malloc()+memset() combo in favor of calloc().
Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
Acked-by: Marek Vasut <marex@denx.de>
*/
#include <common.h>
+#include <errno.h>
#include <malloc.h>
#include <spi.h>
#include <spi_flash.h>
}
cmdsz = SPI_FLASH_CMD_LEN + flash->dummy_byte;
- cmd = malloc(cmdsz);
- memset(cmd, 0, cmdsz);
+ cmd = calloc(1, cmdsz);
+ if (!cmd) {
+ debug("SF: Failed to allocate cmd\n");
+ return -ENOMEM;
+ }
cmd[0] = flash->read_cmd;
while (len) {