From patchwork Thu Sep 12 13:35:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 274556 X-Patchwork-Delegate: sbabic@denx.de 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 6C1C92C0399 for ; Thu, 12 Sep 2013 23:36:35 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 56EB74A064; Thu, 12 Sep 2013 15:36:33 +0200 (CEST) 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 lG0Z6c5IxAv8; Thu, 12 Sep 2013 15:36:33 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0558F4A05E; Thu, 12 Sep 2013 15:36:31 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CD6834A05E for ; Thu, 12 Sep 2013 15:36:23 +0200 (CEST) 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 y3oC6ydYUVEU for ; Thu, 12 Sep 2013 15:36:17 +0200 (CEST) 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 D83614A023 for ; Thu, 12 Sep 2013 15:36:10 +0200 (CEST) Received: from mail114-va3-R.bigfish.com (10.7.14.240) by VA3EHSOBE006.bigfish.com (10.7.40.26) with Microsoft SMTP Server id 14.1.225.22; Thu, 12 Sep 2013 13:36:07 +0000 Received: from mail114-va3 (localhost [127.0.0.1]) by mail114-va3-R.bigfish.com (Postfix) with ESMTP id B375D60105; Thu, 12 Sep 2013 13:36:07 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zzzz1f42h208ch1ee6h1de0h1fdah2073h1202h1e76h1d1ah1d2ah1fc6hzz1de098h1de097h8275bhz2dh2a8h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1b2fh1fb3h1d0ch1d2eh1d3fh1dc1h1dfeh1dffh1e23h1fe8h1ff5h1155h) Received: from mail114-va3 (localhost.localdomain [127.0.0.1]) by mail114-va3 (MessageSwitch) id 1378992966185938_7633; Thu, 12 Sep 2013 13:36:06 +0000 (UTC) Received: from VA3EHSMHS046.bigfish.com (unknown [10.7.14.238]) by mail114-va3.bigfish.com (Postfix) with ESMTP id 15C914E009E; Thu, 12 Sep 2013 13:36:06 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by VA3EHSMHS046.bigfish.com (10.7.99.56) with Microsoft SMTP Server (TLS) id 14.16.227.3; Thu, 12 Sep 2013 13:36:06 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server (TLS) id 14.3.158.2; Thu, 12 Sep 2013 13:36:05 +0000 Received: from fabio-Latitude-E6410.am.freescale.net ([10.29.244.98]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id r8CDZxEk023376; Thu, 12 Sep 2013 06:36:02 -0700 From: Fabio Estevam To: Date: Thu, 12 Sep 2013 10:35:52 -0300 Message-ID: <1378992953-8294-1-git-send-email-fabio.estevam@freescale.com> X-Mailer: git-send-email 1.8.1.2 MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% Cc: Fabio Estevam , u-boot@lists.denx.de Subject: [U-Boot] [PATCH] mmc: fsl_esdhc: Check the result from malloc() 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 malloc can fail, so we should better check its return value before using it. Signed-off-by: Fabio Estevam --- drivers/mmc/fsl_esdhc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c index f87e647..a7170b4 100644 --- a/drivers/mmc/fsl_esdhc.c +++ b/drivers/mmc/fsl_esdhc.c @@ -518,6 +518,8 @@ int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg *cfg) return -1; mmc = malloc(sizeof(struct mmc)); + if (!mmc) + return -ENOMEM; sprintf(mmc->name, "FSL_SDHC"); regs = (struct fsl_esdhc *)cfg->esdhc_base;