From patchwork Mon Oct 8 11:11:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugene Shatokhin X-Patchwork-Id: 189995 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 4988A2C030E for ; Mon, 8 Oct 2012 22:22:39 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752313Ab2JHLWh (ORCPT ); Mon, 8 Oct 2012 07:22:37 -0400 Received: from collab.rosalab.ru ([217.199.216.181]:56388 "EHLO collab.rosalab.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751843Ab2JHLWh (ORCPT ); Mon, 8 Oct 2012 07:22:37 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by collab.rosalab.ru (Postfix) with ESMTP id E55F629C2AC for ; Mon, 8 Oct 2012 15:12:54 +0400 (MSK) X-Virus-Scanned: amavisd-new at rosalab.ru Received: from collab.rosalab.ru ([127.0.0.1]) by localhost (collab.rosalab.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ChKqH22AAqEh; Mon, 8 Oct 2012 15:12:54 +0400 (MSK) Received: from linux-o3sz.pws.msk (unknown [10.168.2.138]) by collab.rosalab.ru (Postfix) with ESMTPSA id 5271029C2A9; Mon, 8 Oct 2012 15:12:54 +0400 (MSK) From: Eugene Shatokhin To: linux-ext4@vger.kernel.org Cc: Eugene Shatokhin Subject: [PATCH] ext4: fix possible memory leak in ext4_xattr_set_acl() Date: Mon, 8 Oct 2012 15:11:12 +0400 Message-Id: <1349694672-16992-1-git-send-email-eugene.shatokhin@rosalab.ru> X-Mailer: git-send-email 1.7.10.4 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org In ext4_xattr_set_acl(), if ext4_journal_start() returns an error, posix_acl_release() will not be called for 'acl' which may result in a memory leak. This patch fixes that. Signed-off-by: Eugene Shatokhin Reviewed-by: Lukas Czerner --- fs/ext4/acl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c index a5c29bb..8535c45 100644 --- a/fs/ext4/acl.c +++ b/fs/ext4/acl.c @@ -410,8 +410,10 @@ ext4_xattr_set_acl(struct dentry *dentry, const char *name, const void *value, retry: handle = ext4_journal_start(inode, EXT4_DATA_TRANS_BLOCKS(inode->i_sb)); - if (IS_ERR(handle)) - return PTR_ERR(handle); + if (IS_ERR(handle)) { + error = PTR_ERR(handle); + goto release_and_out; + } error = ext4_set_acl(handle, inode, type, acl); ext4_journal_stop(handle); if (error == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))