From patchwork Mon Jan 20 17:07:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagannadha Sutradharudu Teki X-Patchwork-Id: 312674 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id E27D72C009B for ; Tue, 21 Jan 2014 04:07:55 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 016E24B3C3; Mon, 20 Jan 2014 18:07:52 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id f16d6V-q99DR; Mon, 20 Jan 2014 18:07:51 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9A5804B3CD; Mon, 20 Jan 2014 18:07:46 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3FD324B3C9 for ; Mon, 20 Jan 2014 18:07:39 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3-5p0Gyy-kTg for ; Mon, 20 Jan 2014 18:07:34 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from va3outboundpool.messaging.microsoft.com (va3ehsobe010.messaging.microsoft.com [216.32.180.30]) by theia.denx.de (Postfix) with ESMTPS id 811804B3C3 for ; Mon, 20 Jan 2014 18:07:28 +0100 (CET) Received: from mail70-va3-R.bigfish.com (10.7.14.249) by VA3EHSOBE001.bigfish.com (10.7.40.21) with Microsoft SMTP Server id 14.1.225.22; Mon, 20 Jan 2014 17:07:25 +0000 Received: from mail70-va3 (localhost [127.0.0.1]) by mail70-va3-R.bigfish.com (Postfix) with ESMTP id 0FC80380115; Mon, 20 Jan 2014 17:07:25 +0000 (UTC) X-Forefront-Antispam-Report: CIP:149.199.60.83; KIP:(null); UIP:(null); IPV:NLI; H:xsj-gw1; RD:unknown-60-83.xilinx.com; EFVD:NLI X-SpamScore: 1 X-BigFish: VPS1(zzzz1f42h2148h208ch1ee6h1de0h1fdah2073h2146h1202h1e76h2189h1d1ah1d2ah21bch1fc6hzz1de098h8275bh1de097hz2fh95h839hd24hf0ah119dh1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h14ddh1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1b0ah224fh1d0ch1d2eh1d3fh1dc1h1dfeh1dffh1e1dh1e23h1fe8h1ff5h2218h2216h226dh24afh2327h2336h2438h2461h2487h906i1155h) Received-SPF: pass (mail70-va3: domain of xilinx.com designates 149.199.60.83 as permitted sender) client-ip=149.199.60.83; envelope-from=jagannadha.sutradharudu-teki@xilinx.com; helo=xsj-gw1 ; helo=xsj-gw1 ; Received: from mail70-va3 (localhost.localdomain [127.0.0.1]) by mail70-va3 (MessageSwitch) id 1390237643259952_16571; Mon, 20 Jan 2014 17:07:23 +0000 (UTC) Received: from VA3EHSMHS011.bigfish.com (unknown [10.7.14.241]) by mail70-va3.bigfish.com (Postfix) with ESMTP id 3002D440047; Mon, 20 Jan 2014 17:07:23 +0000 (UTC) Received: from xsj-gw1 (149.199.60.83) by VA3EHSMHS011.bigfish.com (10.7.99.21) with Microsoft SMTP Server id 14.16.227.3; Mon, 20 Jan 2014 17:07:21 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-smtp1) by xsj-gw1 with esmtp (Exim 4.63) (envelope-from ) id 1W5IJl-0001py-L1; Mon, 20 Jan 2014 09:07:21 -0800 From: Jagannadha Sutradharudu Teki To: Date: Mon, 20 Jan 2014 22:37:15 +0530 X-Mailer: git-send-email 1.8.3 X-RCIS-Action: ALLOW MIME-Version: 1.0 Message-ID: <3f788836-20ae-42e9-88aa-2741bd033285@VA3EHSMHS011.ehs.local> X-OriginatorOrg: xilinx.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% Cc: Tom Rini , Jagannadha Sutradharudu Teki Subject: [U-Boot] [PATCH v3] sf: ops: Squash the malloc+memset combo X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Squash the malloc()+memset() combo in favor of calloc(). Signed-off-by: Jagannadha Sutradharudu Teki --- Changes for v3: - Use errno.h Changes for v2: - used debug() drivers/mtd/spi/sf_ops.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/spi/sf_ops.c b/drivers/mtd/spi/sf_ops.c index 1f1bb36..ef91b92 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) {