From patchwork Tue Mar 31 05:34:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rayagonda Kokatanur X-Patchwork-Id: 1264530 X-Patchwork-Delegate: van.freenix@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.a=rsa-sha256 header.s=google header.b=WpRboXzQ; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48rygx1GPRz9sQt for ; Tue, 31 Mar 2020 16:34:37 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id ACF9581933; Tue, 31 Mar 2020 07:34:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.b="WpRboXzQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 81B638192F; Tue, 31 Mar 2020 07:34:27 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 73CC981923 for ; Tue, 31 Mar 2020 07:34:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rayagonda.kokatanur@broadcom.com Received: by mail-wm1-x342.google.com with SMTP id b12so1080329wmj.3 for ; Mon, 30 Mar 2020 22:34:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YiVjkigwHIujR+LXZQn/7z1bsnNHVS6z5qREoCkU/Og=; b=WpRboXzQvxUphCa9NFkA2z5Dyfp4hpVomdwOnDUBw6k/iRe2J5y4SpVKKSIbfrcMg8 7/Eo2SbVzcMXl0X29i3LUIQ/mQPbNUOX9ONxwBqJMxDuNJQgWW5lcm4xzwEnU74DpvRW ROGIyogJ6edLPwgUnPCzifCCzwE8soDsSyxT8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YiVjkigwHIujR+LXZQn/7z1bsnNHVS6z5qREoCkU/Og=; b=Lsq1rJ4LBMeU2jz7APEnrAJUHyDFNjMEFwk4nDKTVwjnvKi8c8yzvysCnyz8+BlM7T EWncfFRTz86G8T33elPByFaRlpVOr+FrN5mjqKLlid+WqfDLAyc5oA/ayiMeWGP0mSbX NObqxdBaANQ6bOdEp3y2O+gcdpnXy0KCFU5/FEVtpgb9RnKC0O2qhRFTKB1UtfsN8KLw z/oNhUowSa43x+aNNODpg2OUAEbNbvJMnQ8YHS4Cv5EKNSrxNQKNuN1LaBea+lKJlaZX RabFyaRIHjxgTrgNFgy6f3nx+3zEnw2eRtkkUrWmuCY+itq9RzZ5oVJk8jAQMSF5XNc9 XiEQ== X-Gm-Message-State: ANhLgQ2TBoZyT98Op4y8FAWXBK04WM5jp0bSgk5QP95xtDzk3BvyiM/P yy4R194uW8uNY2wo3QT0ASxZwnJ1RPOczTKAo4EyinZUMO3bShE6h6TLeokSt4OshhK4KgQL56N bvRQll84arTmhC4b7T4ZKJw1Uwm4SWemXwngW9Lvg5FXakru90eVo9vIfadmobAI0zFFX/SiMt0 jcZMVPWg== X-Google-Smtp-Source: ADFU+vuef4OA0Dj5z4NIBVUhtEyxX6hCW1t73SaXMabu9oBgn/6NFlR9p1j0/KgJ71TX9g7DVNe5GA== X-Received: by 2002:a1c:196:: with SMTP id 144mr1639525wmb.100.1585632863465; Mon, 30 Mar 2020 22:34:23 -0700 (PDT) Received: from rayagonda.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id w204sm2374854wma.1.2020.03.30.22.34.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Mar 2020 22:34:22 -0700 (PDT) From: Rayagonda Kokatanur To: u-boot@lists.denx.de, panto@antoniou-consulting.com, Bharat Kumar Reddy Gooty , Arun Parameswaran , Vladimir Olovyannikov Cc: Rayagonda Kokatanur Subject: [PATCH v1 1/4] drivers: mmc: iproc_sdhci: fix possible memory leak Date: Tue, 31 Mar 2020 11:04:03 +0530 Message-Id: <20200331053406.23063-2-rayagonda.kokatanur@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200331053406.23063-1-rayagonda.kokatanur@broadcom.com> References: <20200331053406.23063-1-rayagonda.kokatanur@broadcom.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean From: Bharat Kumar Reddy Gooty Free the pointer variable 'iproc_sdhci' upon failure to fix possible memory leak. Signed-off-by: Bharat Kumar Reddy Gooty Signed-off-by: Rayagonda Kokatanur --- drivers/mmc/iproc_sdhci.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/iproc_sdhci.c b/drivers/mmc/iproc_sdhci.c index 831dd32eb7..36ecdba5c6 100644 --- a/drivers/mmc/iproc_sdhci.c +++ b/drivers/mmc/iproc_sdhci.c @@ -176,8 +176,7 @@ static int iproc_sdhci_probe(struct udevice *dev) u32 f_min_max[2]; int ret; - iproc_host = (struct sdhci_iproc_host *) - malloc(sizeof(struct sdhci_iproc_host)); + iproc_host = malloc(sizeof(struct sdhci_iproc_host)); if (!iproc_host) { printf("%s: sdhci host malloc fail!\n", __func__); return -ENOMEM; @@ -198,6 +197,7 @@ static int iproc_sdhci_probe(struct udevice *dev) "clock-freq-min-max", f_min_max, 2); if (ret) { printf("sdhci: clock-freq-min-max not found\n"); + free(iproc_host); return ret; } host->max_clk = f_min_max[1]; @@ -212,8 +212,10 @@ static int iproc_sdhci_probe(struct udevice *dev) ret = sdhci_setup_cfg(&plat->cfg, &iproc_host->host, f_min_max[1], f_min_max[0]); - if (ret) + if (ret) { + free(iproc_host); return ret; + } iproc_host->host.mmc = &plat->mmc; iproc_host->host.mmc->dev = dev;