]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/mtd/spi/sf_ops.c
sf: ops: Squash the malloc+memset combo
[karo-tx-uboot.git] / 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) {