]> git.sur5r.net Git - u-boot/commitdiff
sf: ops: Squash the malloc+memset combo
authorJagannadha Sutradharudu Teki <jagannadha.sutradharudu-teki@xilinx.com>
Tue, 4 Feb 2014 16:06:13 +0000 (21:36 +0530)
committerJagannadha Sutradharudu Teki <jaganna@xilinx.com>
Mon, 17 Mar 2014 16:24:57 +0000 (21:54 +0530)
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>
drivers/mtd/spi/sf_ops.c

index 1f1bb3606590319e43110923ca09711a16a5c721..ef91b924d7d69f75cb123b8e5a9385c090013d5a 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #include <common.h>
+#include <errno.h>
 #include <malloc.h>
 #include <spi.h>
 #include <spi_flash.h>
@@ -381,8 +382,11 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
        }
 
        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) {