From patchwork Fri Sep 30 19:40:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 117190 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 E3050B6F65 for ; Sat, 1 Oct 2011 05:40:00 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932344Ab1I3Tj7 (ORCPT ); Fri, 30 Sep 2011 15:39:59 -0400 Received: from e34.co.us.ibm.com ([32.97.110.152]:44795 "EHLO e34.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932073Ab1I3Tj6 (ORCPT ); Fri, 30 Sep 2011 15:39:58 -0400 Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by e34.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p8UJdwCO006766 for ; Fri, 30 Sep 2011 13:39:58 -0600 Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p8UJdu7b197664 for ; Fri, 30 Sep 2011 13:39:56 -0600 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p8UJdued018160 for ; Fri, 30 Sep 2011 13:39:56 -0600 Received: from tux1.beaverton.ibm.com ([9.47.67.50]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p8UJdul3018019; Fri, 30 Sep 2011 13:39:56 -0600 Received: by tux1.beaverton.ibm.com (Postfix, from userid 501) id 0839D13E890; Fri, 30 Sep 2011 12:39:53 -0700 (PDT) Date: Fri, 30 Sep 2011 12:40:05 -0700 From: "Darrick J. Wong" To: "Theodore Ts'o" Cc: linux-ext4 Subject: [PATCH] e2fsck: When restarting fsck on account of MMP, zero ctx->fs after fs is freed Message-ID: <20110930194005.GT12086@tux1.beaverton.ibm.com> Reply-To: djwong@us.ibm.com MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.17+20080114 (2008-01-14) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org If MMP is enabled and e2fsck determines that it needs to restart itself on account of various MMP conditions, it will close the current fs and jump back to the start of fs checking. However, closing fs also frees it, which means that we need to set ctx->fs to NULL to prevent subsequent open code from accessing the old deleted pointer. (This fix came up while testing the metadata checksumming patchset) Signed-off-by: Darrick J. Wong --- e2fsck/unix.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/e2fsck/unix.c b/e2fsck/unix.c index f980962..37cfb00 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -1351,6 +1351,7 @@ failure: * Restart in order to reopen fs but this time start mmp. */ if (flags & EXT2_FLAG_SKIP_MMP) { + ctx->fs = NULL; ext2fs_close(fs); flags &= ~EXT2_FLAG_SKIP_MMP; goto restart;