From patchwork Fri Jul 13 13:35:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 141888 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp815144ljj; Fri, 13 Jul 2018 06:36:17 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcf6292eYMRYb73p9TCmthSPjokSXy1y4n+G/DTtgcPxFNgrYOb2JxxodRvdWWedJVY1jtg X-Received: by 2002:a50:88a6:: with SMTP id d35-v6mr7288317edd.239.1531488977615; Fri, 13 Jul 2018 06:36:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531488977; cv=none; d=google.com; s=arc-20160816; b=C2SD8cKaPn3y2dHasS+bRi0nAe6FJ9J7/J0xkqyS4dyXdEuU44TmxE8CbQC9+z/ecE AtQSU8kR2gN/BvwScDbVUr9bFTYoNs74RqWY6oFr5UtSbEe1KhyhMoyzf39Qp4rIuEHW n+S58zx0etadYFrSDv+Umj055ImKAp/7A1/nREQVI0DLWJPPht9ADwgdRqXsDlGkQIf1 80BpxTeBb6jqj0pXH/2/i9zqF/bij3OY35kMU73dvQfDSZ1qxtvNWbTr6AK8e0eC35CE lU3j+++QNq5BIf9KQKe0T+v6lk385pnsHD5aUr7HUY+lnHcHaN7VYPG7ZnLU+eFfbrZN UJ/A== 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=5fQn9IdkJu4M6+ARZXkWnmxCyzsnehG6jCoxAjnSCag=; b=Uby6Io6NH2tmcvGpNMjBt6tpuHz4OYOP60I0aeCGJUk0Lk/xqt4h7l+ReDa3Vg3+0U lyJGE2HJwEKlqx+L/K7MyyotIiaqehMdd0ppi+MMq3KhOkggAYB7nKcZlWDD5iJuCg+5 MCzvl0JUcJmoDtCJ2WsevfHQqkmb9dnRHK5M9ySrxttcFX6y20g+6Dib1qx4Pl8IweSL 6kZsA4VEcQNfCTZ3RmqJq3km9gXZwsSpdbmWGhgf8ksazCWgmI8IkYeHsXuPGsfRvaJM 1CM/2Pro8jrvDHrYq7WEklIDStQ0X8gsz+t15J9qdLzev8CDCcdzgIym6oVWNryvLE8i SK2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=M8UkMSc0; 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 d11-v6si2687851edo.400.2018.07.13.06.36.17; Fri, 13 Jul 2018 06:36:17 -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=M8UkMSc0; 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 2CE3AC21E44; Fri, 13 Jul 2018 13:36:11 +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 3910EC22059; Fri, 13 Jul 2018 13:35:55 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3BB4BC21E44; Fri, 13 Jul 2018 13:35:52 +0000 (UTC) Received: from mail-lf0-f67.google.com (mail-lf0-f67.google.com [209.85.215.67]) by lists.denx.de (Postfix) with ESMTPS id D976DC21DB3 for ; Fri, 13 Jul 2018 13:35:51 +0000 (UTC) Received: by mail-lf0-f67.google.com with SMTP id m12-v6so27189170lfc.10 for ; Fri, 13 Jul 2018 06:35:51 -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=Z2YlSjN4RoV9gSr2+KJC7MCILVkRHTCAcGGxfEuqVkQ=; b=M8UkMSc0EtCbAAIl28PIi+PD6lb1/lr3EodJX+XsnMxXsCKetzNktuu6lAXFLtTHmt MIeNwEc+ROGrdejxcMUM2m6tZkrUFvirob/2OsxAkny7X57O5hWrnJ7mhJTKT261sgtT whqhUoRhgEWesuosC8reB+pjSvyA5Zj14BqWg= 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=Z2YlSjN4RoV9gSr2+KJC7MCILVkRHTCAcGGxfEuqVkQ=; b=NQpHMltCccx65DTSKC7+dNheYbUG8s576wtp+ovAF97zED07SDzDb/w4F1AqRnfgKr 6jxdSjRdljVngfFPEbxE137nLlwJTflLIbeLCTIKjSb73GzUocZFhkZgOAsmW9LlxM9l tlCkhv/KR7S+8lZ3+yObkynAIlYzgKMFqgRVZsW6i1VqeW0Jyfzm4nS3BmE0J/png2Zc YGdG9Rj/g+DhilsnXus+sBuqm+7f+ZXMQBbPE0D2SYkbTnma3R6HP1mRG+4Z6e/T1Xkv 5+ifrgZ1TDPC1isge8tbxymmqXegZR+NwyVuXOKzW2Wqo19t1ThmXHtHVbf3yIOww3j4 XoTw== X-Gm-Message-State: AOUpUlH65RwTiqOAD4Ga++kSXyrfF2Syq5PANHD0ps0PQI6PoZRQ+rLS DoxlX950td/0n6B1BmIPB2dF9G+OOtE= X-Received: by 2002:a19:d7d1:: with SMTP id q78-v6mr4954524lfi.40.1531488951082; Fri, 13 Jul 2018 06:35:51 -0700 (PDT) Received: from localhost ([195.238.92.132]) by smtp.gmail.com with ESMTPSA id w2-v6sm2576350lje.73.2018.07.13.06.35.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Jul 2018 06:35:50 -0700 (PDT) From: Sam Protsenko To: u-boot@lists.denx.de Date: Fri, 13 Jul 2018 16:35:46 +0300 Message-Id: <20180713133547.21094-2-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180713133547.21094-1-semen.protsenko@linaro.org> References: <20180713133547.21094-1-semen.protsenko@linaro.org> Cc: Tom Rini Subject: [U-Boot] [PATCH v2 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 --- Changes in v2: - None 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;