From patchwork Thu Jul 12 21:52:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 141839 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp69675ljj; Thu, 12 Jul 2018 14:53:58 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcyJ9T/DuQf1ASyOQ3mw3fA4cyVrcXNswaiXGx6pjErdTnZhfP96b4/GU8lfnwqipc281Tl X-Received: by 2002:a50:95ab:: with SMTP id w40-v6mr4087326eda.33.1531432438694; Thu, 12 Jul 2018 14:53:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531432438; cv=none; d=google.com; s=arc-20160816; b=xN3+lScuF/UOhDK+eiLwPILIQ3rfKaUbx1XpUlDiQUsLiAUQ1RLtnHyAPGePVEIvL2 jiYJ0SfRJ8ZxbSmO5dkrv+sJrHRCE2ZrzERrK+YLPr4oOA0LUBu5x+ACu2tHXxymr784 bd+wtTE1MFIMbSVAkFx69RGNxilPdaDEV7OlNFZUVuYfZRlNmeh1q+ZGQDfPSX6hu1Oe 3Q4W3YRzbEaw/yG2d9iGE4jqFNcOV/h9JJtB90zO3l5kmOs+Mxglgncp4C5X3hlkjg12 PDSFtWEfKhPPw6D0kdMMXz2ZzrFf8fUzSPKk4gx99nO1pPV1B2MJUmIyltnDYuN3iDg3 sAnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:arc-authentication-results; bh=ONFZ9goB7dD7LnJ+PTgySZi69nGsDWOIqPycqyZuRYA=; b=q7Gs+7Lh/9gU85pSDOHk04s2jRO34Fnud/qoI98xgKmTcbv+eq6tqe0yb78svxSL6S 7rp/Lyis8fYM1LfdoTMuebSgUXzc381GZeJO5eGepfXglbJlybWPM4l1M3fNzw0bh7gC amZQcmwv1BNZqKPIFMuq7NjRzwx5AmqyCspJxTBh+4U0RFcpkT047SrKNKm5eLRsEdCo Wn+H22OpR057C2cjtjmVP1n/3rLLG1fwWT9qH3a1muyoWw0Tx7RBau5jKeCA622dtkS6 6UsM1YtbkJ0LzaQLqitMTofDXI3nLB3Dz2ZqH8z3ZqdEkd6vGZmFAYq37AYAIPnPOAqH Hj8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=VP+EXhTY; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id s19-v6si2769600edc.383.2018.07.12.14.53.58; Thu, 12 Jul 2018 14:53:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=VP+EXhTY; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id 4A883C21FC1; Thu, 12 Jul 2018 21:53:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 3753CC21FC5; Thu, 12 Jul 2018 21:53:02 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 01496C21E7E; Thu, 12 Jul 2018 21:52:59 +0000 (UTC) Received: from mail-lf0-f68.google.com (mail-lf0-f68.google.com [209.85.215.68]) by lists.denx.de (Postfix) with ESMTPS id 864EAC21D56 for ; Thu, 12 Jul 2018 21:52:57 +0000 (UTC) Received: by mail-lf0-f68.google.com with SMTP id a134-v6so25468388lfe.6 for ; Thu, 12 Jul 2018 14:52:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=z/Zp2sXUf6MTt31h9qQF1whfdNvlIu9/DyEhonIqC9o=; b=VP+EXhTYfOAPjoYOT6kiZNFaCGJvfp8+70v7hVv2i+pwd3QVdLMDO1jZ1l+5idL+de Qz+ubhuIHELpJf1BfteM4yQbTVlI3xS+OemmPJqTGFWgZI1/4xnTesdLBNrGEpSXH4uL dZRxpCfwIoO7ydHLGTuyuDe7SNa6TRw9gC3z4= 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=z/Zp2sXUf6MTt31h9qQF1whfdNvlIu9/DyEhonIqC9o=; b=XD50fB3i+5cEWEBaFxUppiwJfIzNiN3WwTi4lIfGgYL6Z2VUppI+8b786hhFPBCjH5 l+/lCokuX+tLkUhwaLSsNdlVtfgbI7PBFclzx25iqB+xBWYnYWG12bvDoA7JgURq5puB xILoZnISXlH6eE5U3zgMn2A3BqOM5StiUb4GrmtdLa48c1dQKQijiuUP6fcWZmh9eTL2 ytRCKAFs5U21V9yTKhbSnJ8cP2K84awvvCIjMfWfEZSyIoM6f0glStq1IvJc3cp+/zDQ /ykX3q0PphlxSIQ3iQZ4EqkwnEtv8uh0oma8Ey1xD790fD4A73EQAV20qR1EFNFRcdsP UUXg== X-Gm-Message-State: AOUpUlFgf0Onn94FMcVvZeoK+zG6XXjm++n35gOfUfErhbDQtrvnAp3w q0LdgnJ1Lk9UuoHRxkYDR4W94dHYP9M= X-Received: by 2002:a19:dd81:: with SMTP id w1-v6mr2944363lfi.114.1531432376760; Thu, 12 Jul 2018 14:52:56 -0700 (PDT) Received: from localhost ([195.238.92.132]) by smtp.gmail.com with ESMTPSA id p88-v6sm3495940ljp.90.2018.07.12.14.52.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Jul 2018 14:52:56 -0700 (PDT) From: Sam Protsenko To: u-boot@lists.denx.de Date: Fri, 13 Jul 2018 00:52:52 +0300 Message-Id: <20180712215253.4290-2-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180712215253.4290-1-semen.protsenko@linaro.org> References: <20180712215253.4290-1-semen.protsenko@linaro.org> Cc: Tom Rini Subject: [U-Boot] [PATCH 2/3] dfu: Fix memory leak in dfu_init_env_entities() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" In case of error in dfu_init_env_entities(), env_bkp will leak. Fix it by providing single return path. Signed-off-by: Sam Protsenko Acked-by: Lukasz Majewski --- drivers/dfu/dfu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c index a3c09334b7..5b9abd685d 100644 --- a/drivers/dfu/dfu.c +++ b/drivers/dfu/dfu.c @@ -56,7 +56,7 @@ int dfu_init_env_entities(char *interface, char *devstr) { const char *str_env; char *env_bkp; - int ret; + int ret = 0; #ifdef CONFIG_SET_DFU_ALT_INFO set_dfu_alt_info(interface, devstr); @@ -71,11 +71,12 @@ int dfu_init_env_entities(char *interface, char *devstr) ret = dfu_config_entities(env_bkp, interface, devstr); if (ret) { pr_err("DFU entities configuration failed!\n"); - return ret; + goto done; } +done: free(env_bkp); - return 0; + return ret; } static unsigned char *dfu_buf;