From patchwork Tue May 10 18:12:57 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Gouriou X-Patchwork-Id: 95024 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 50F6F1007D9 for ; Wed, 11 May 2011 04:19:37 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751502Ab1EJSNJ (ORCPT ); Tue, 10 May 2011 14:13:09 -0400 Received: from smtp-out.google.com ([216.239.44.51]:52112 "EHLO smtp-out.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750937Ab1EJSNI (ORCPT ); Tue, 10 May 2011 14:13:08 -0400 Received: from kpbe17.cbf.corp.google.com (kpbe17.cbf.corp.google.com [172.25.105.81]) by smtp-out.google.com with ESMTP id p4AID7aS002334; Tue, 10 May 2011 11:13:07 -0700 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1305051187; bh=Xyfyl707bB7lCJhr1v60STGi5lw=; h=From:To:Cc:Subject:Date:Message-Id; b=rShw4DhtV59x9bg4zuR1Xrpbr+VQxMMLxx506u7Pk8kcvxFuuRMucUkVzbMHJoCSt zIzpgMaG1niP97g+sAaOQ== DomainKey-Signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns; h=from:to:cc:subject:date:message-id:x-mailer; b=wdi7aBNCwz/boA12yR2IFWEh/ZmWeKxLZ5P883V6je7A+aH30CrqAJ4aQvgg0wVE9 CVFhsXZ2e805mFzne0iHQ== Received: from egouriou.mtv.corp.google.com (egouriou.mtv.corp.google.com [172.18.96.37]) by kpbe17.cbf.corp.google.com with ESMTP id p4AID6rc003553; Tue, 10 May 2011 11:13:06 -0700 Received: by egouriou.mtv.corp.google.com (Postfix, from userid 117637) id EA8F218411A; Tue, 10 May 2011 11:13:05 -0700 (PDT) From: Eric Gouriou To: "Theodore Ts'o" Cc: linux-ext4@vger.kernel.org, Eric Gouriou Subject: [PATCH] ext4: fix unbalanced up_write() in ext4_ext_truncate() error path Date: Tue, 10 May 2011 11:12:57 -0700 Message-Id: <1305051177-18452-1-git-send-email-egouriou@google.com> X-Mailer: git-send-email 1.7.3.1 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org ext4_ext_truncate() should not invoke up_write(&EXT4_I(inode)->i_data_sem) when ext4_orphan_add() returns an error, as it hasn't performed a down_write() yet. This trivial patch fixes this by moving the up_write() invocation above the out_stop label. Signed-off-by: Eric Gouriou --- fs/ext4/extents.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index e363f21..ae3c9e6 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -3443,8 +3443,9 @@ void ext4_ext_truncate(struct inode *inode) if (IS_SYNC(inode)) ext4_handle_sync(handle); -out_stop: up_write(&EXT4_I(inode)->i_data_sem); + +out_stop: /* * If this was a simple ftruncate() and the file will remain alive, * then we need to clear up the orphan record which we created above.