From patchwork Thu Mar 13 05:01:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gui Hecheng X-Patchwork-Id: 3821951 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0918D9F72D for ; Thu, 13 Mar 2014 05:09:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 28BA6201FD for ; Thu, 13 Mar 2014 05:09:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2CA61201E9 for ; Thu, 13 Mar 2014 05:09:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751154AbaCMFJd (ORCPT ); Thu, 13 Mar 2014 01:09:33 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:3901 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751092AbaCMFJb (ORCPT ); Thu, 13 Mar 2014 01:09:31 -0400 X-IronPort-AV: E=Sophos;i="4.97,644,1389715200"; d="scan'208";a="9688067" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 13 Mar 2014 13:05:37 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s2D56Gxs003962 for ; Thu, 13 Mar 2014 13:09:27 +0800 Received: from localhost.localdomain ([10.167.226.111]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2014031313033133-603910 ; Thu, 13 Mar 2014 13:03:31 +0800 From: Gui Hecheng To: linux-btrfs@vger.kernel.org Cc: Gui Hecheng Subject: [PATCH] btrfs-progs: skip erroneous free before initialization Date: Thu, 13 Mar 2014 13:01:31 +0800 Message-Id: <1394686891-23271-2-git-send-email-guihc.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1394686891-23271-1-git-send-email-guihc.fnst@cn.fujitsu.com> References: <1394686891-23271-1-git-send-email-guihc.fnst@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2014/03/13 13:03:31, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2014/03/13 13:06:43, Serialize complete at 2014/03/13 13:06:43 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 If the list is not initialized, don't try to free it. Otherwise it will cause segmentfault. Signed-off-by: Gui Hecheng --- mkfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mkfs.c b/mkfs.c index d7049c9..df22c3a 100644 --- a/mkfs.c +++ b/mkfs.c @@ -965,7 +965,7 @@ static int make_image(char *source_dir, struct btrfs_root *root, int out_fd) ret = lstat(source_dir, &root_st); if (ret) { fprintf(stderr, "unable to lstat the %s\n", source_dir); - goto fail; + goto out; } INIT_LIST_HEAD(&dir_head.list); @@ -987,6 +987,7 @@ fail: list_del(&dir_entry->list); free(dir_entry); } +out: fprintf(stderr, "Making image is aborted.\n"); return -1; }