From patchwork Thu Nov 15 04:47:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kenji Okimoto X-Patchwork-Id: 1746991 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id CE49EDFFEC for ; Thu, 15 Nov 2012 04:58:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2992649Ab2KOE6T (ORCPT ); Wed, 14 Nov 2012 23:58:19 -0500 Received: from mail.clear-code.com ([219.94.234.64]:45974 "EHLO mail.clear-code.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2992568Ab2KOE6R (ORCPT ); Wed, 14 Nov 2012 23:58:17 -0500 Received: from brownian.local.clear-code.com (212.19.100.220.dy.bbexcite.jp [220.100.19.212]) by mail.clear-code.com (Postfix) with ESMTPSA id 508B8E0DC5; Thu, 15 Nov 2012 13:47:48 +0900 (JST) From: Kenji Okimoto To: linux-btrfs@vger.kernel.org Cc: Kenji Okimoto Subject: [PATCH 3/3] btrfs-progs: plug memory leaks in btrfs_scan_one_dir() reported by cppcheck. Date: Thu, 15 Nov 2012 13:47:52 +0900 Message-Id: <1352954872-13770-4-git-send-email-okimoto@clear-code.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1352954872-13770-1-git-send-email-okimoto@clear-code.com> References: <1352954872-13770-1-git-send-email-okimoto@clear-code.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org [utils.c:983]: (error) Memory leak: fullpath Signed-off-by: Kenji Okimoto --- utils.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utils.c b/utils.c index 205e667..3efb3af 100644 --- a/utils.c +++ b/utils.c @@ -980,6 +980,7 @@ again: dirp = opendir(dirname); if (!dirp) { fprintf(stderr, "Unable to open %s for scanning\n", dirname); + free(fullpath); return -ENOENT; } while(1) { @@ -1030,6 +1031,7 @@ again: free(pending); pending = list_entry(pending_list.next, struct pending_dir, list); + free(fullpath); list_del(&pending->list); closedir(dirp); dirp = NULL; @@ -1038,6 +1040,7 @@ again: ret = 0; fail: free(pending); + free(fullpath); if (dirp) closedir(dirp); return ret;