From patchwork Thu Aug 27 15:38:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byongho Lee X-Patchwork-Id: 7085761 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D9058BEEC1 for ; Thu, 27 Aug 2015 15:38:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0A765206AF for ; Thu, 27 Aug 2015 15:38:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2F07820864 for ; Thu, 27 Aug 2015 15:38:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753780AbbH0Pig (ORCPT ); Thu, 27 Aug 2015 11:38:36 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:33403 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753615AbbH0Pif (ORCPT ); Thu, 27 Aug 2015 11:38:35 -0400 Received: by pacti10 with SMTP id ti10so29973273pac.0 for ; Thu, 27 Aug 2015 08:38:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=tiLUTeGFYzwme0mF87RyMqgh5QTAhb/FN+4hrENk+G8=; b=dQCrnNHZgZTzMV0gzUMql+Y9KN8/ak6oTe0j74qBviN0YBAuSYn9ePNCMSDs+D/xXE qi+ohgUjHrGXYubymyRF7Zz6Qe5H0GQnJQtmRZr9tsqkru4hX2dDMva4qmoUy1xoRfY3 rf0lJ+WgSRXIwfc5w77SewjgHz7cfmoanhuqM8LDgxFIDYgeXqHPUt0eZb2s15m+kQ+V 7krX4GOAzkz6LuOb84RXvlBb+IbAz1Xs6skJlVUfn8j3ygfIxplInFyBxRDP111537v+ urnZVu2g+8QqGid+QWPeB42YODt7fBXaYX0COc+I/SBv1YzKWeOb/B9AkA753xITdSHF AdZA== X-Received: by 10.68.143.70 with SMTP id sc6mr7351938pbb.87.1440689914713; Thu, 27 Aug 2015 08:38:34 -0700 (PDT) Received: from arch-nb.localdomain ([175.118.89.137]) by smtp.gmail.com with ESMTPSA id vw6sm2844831pab.14.2015.08.27.08.38.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Aug 2015 08:38:33 -0700 (PDT) From: Byongho Lee To: linux-btrfs@vger.kernel.org Subject: [PATCH 2/3] btrfs-progs: fix memory leak in btrfs-map-logical main() Date: Fri, 28 Aug 2015 00:38:17 +0900 Message-Id: <1440689898-35178-3-git-send-email-bhlee.kernel@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1440689898-35178-1-git-send-email-bhlee.kernel@gmail.com> References: <1440689898-35178-1-git-send-email-bhlee.kernel@gmail.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In btrfs-map-logical main(), strdup() allocates memory to output_file, but that memory is not freed. So add missing free() calls before return. Signed-off-by: Byongho Lee --- btrfs-map-logical.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c index a88e56e39dbb..d9fa6b29d3c9 100644 --- a/btrfs-map-logical.c +++ b/btrfs-map-logical.c @@ -262,6 +262,7 @@ int main(int ac, char **av) root = open_ctree(dev, 0, 0); if (!root) { fprintf(stderr, "Open ctree failed\n"); + free(output_file); exit(1); } @@ -354,6 +355,7 @@ out_close_fd: if (output_file && out_fd != 1) close(out_fd); close: + free(output_file); close_ctree(root); if (ret < 0) ret = 1;