From patchwork Mon May 9 15:33:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tao Ma X-Patchwork-Id: 94778 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 15D21B6F10 for ; Tue, 10 May 2011 01:33:46 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751680Ab1EIPdp (ORCPT ); Mon, 9 May 2011 11:33:45 -0400 Received: from oproxy4-pub.bluehost.com ([69.89.21.11]:47635 "HELO oproxy4-pub.bluehost.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751353Ab1EIPdo (ORCPT ); Mon, 9 May 2011 11:33:44 -0400 Received: (qmail 3883 invoked by uid 0); 9 May 2011 15:33:43 -0000 Received: from unknown (HELO box585.bluehost.com) (66.147.242.185) by cpoproxy1.bluehost.com with SMTP; 9 May 2011 15:33:43 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=tao.ma; h=Received:From:To:Subject:Date:Message-Id:X-Mailer:X-Identified-User; b=kgOzl5tLVyz1+D51JQOa6hBK/8s57fJvnKaIBsp3Y+58WqTcL8Oda4Y7+hcKIwqTDFydQWTa1oYjtZJvkHQRE3Z+RDmierdmxrDLAst4XWL4in8nXQqG0nuiAHYhnOUQ; Received: from [114.251.86.0] (helo=taoma-linux.taobao.ali.com) by box585.bluehost.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1QJSSs-0001aA-CY for linux-ext4@vger.kernel.org; Mon, 09 May 2011 09:33:43 -0600 From: Tao Ma To: linux-ext4@vger.kernel.org Subject: [PATCH] mke2fs: Avoid segmentation fault in ext2fs_alloc_generic_bmap. Date: Mon, 9 May 2011 23:33:27 +0800 Message-Id: <1304955207-4066-1-git-send-email-tm@tao.ma> X-Mailer: git-send-email 1.7.1 X-Identified-User: {1390:box585.bluehost.com:colyli:tao.ma} {sentby:smtp auth 114.251.86.0 authed with tm@tao.ma} Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Tao Ma In case of error, ext2fs_alloc_generic_bmap free the memory in the wrong order. So change it to free description first and then the bitmap. Signed-off-by: Tao Ma --- lib/ext2fs/gen_bitmap64.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/lib/ext2fs/gen_bitmap64.c b/lib/ext2fs/gen_bitmap64.c index df095ac..8b9e4c5 100644 --- a/lib/ext2fs/gen_bitmap64.c +++ b/lib/ext2fs/gen_bitmap64.c @@ -129,8 +129,8 @@ errcode_t ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic, retval = bitmap->bitmap_ops->new_bmap(fs, bitmap); if (retval) { - ext2fs_free_mem(&bitmap); ext2fs_free_mem(&bitmap->description); + ext2fs_free_mem(&bitmap); return retval; }