From: Jagannadha Sutradharudu Teki Date: Tue, 4 Feb 2014 16:06:13 +0000 (+0530) Subject: sf: ops: Squash the malloc+memset combo X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=c6136aad91da493c446f22af8f5d774a74dec9d1;p=project%2Fbcm63xx%2Fu-boot.git sf: ops: Squash the malloc+memset combo Squash the malloc()+memset() combo in favor of calloc(). Signed-off-by: Jagannadha Sutradharudu Teki Acked-by: Marek Vasut --- diff --git a/drivers/mtd/spi/sf_ops.c b/drivers/mtd/spi/sf_ops.c index 1f1bb36065..ef91b924d7 100644 --- a/drivers/mtd/spi/sf_ops.c +++ b/drivers/mtd/spi/sf_ops.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include @@ -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) {