From patchwork Tue Jan 27 06:16:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 5714821 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D21289F1D6 for ; Tue, 27 Jan 2015 06:17:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 12481201CE for ; Tue, 27 Jan 2015 06:17:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3B488201CD for ; Tue, 27 Jan 2015 06:17:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751553AbbA0GRk (ORCPT ); Tue, 27 Jan 2015 01:17:40 -0500 Received: from mail-pa0-f49.google.com ([209.85.220.49]:59619 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751195AbbA0GRk (ORCPT ); Tue, 27 Jan 2015 01:17:40 -0500 Received: by mail-pa0-f49.google.com with SMTP id fa1so16435852pad.8 for ; Mon, 26 Jan 2015 22:17:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=mOsOp9x9diL7EGza9HUliOjIiqHfZPLMhbcHFLRt0kQ=; b=mHrQA/JnWl6p3EWr2lx+Y/bQI+Yv38nFF1kdbv31x9/vymGlQ7eIxUOX2In6SnuP6L WqUGuanozHMVMCR6y6rH4tYYzwTlF6H7mkT+Y2kMhjW0XD1hR3isn87LMM9ozgSPLuEW 5k67ECI6SdQ3HIGBWJxsLaVCsDdFc/QHcCUpX87OEk10pe2U9orlGcxu7lCsNFHuq+Up ADMe6wYggQF0W+4V5P/aMHFxborUJTCtZSSolkVFj13jO9KXVH7KiQxfensgAXDnpDnr KLU6qAlBk2X020DDMhBHZJU2yzgm2ghpbEtg39pomW+ZPUx3QVP86MKedug6ITxCDTEB nYdw== X-Gm-Message-State: ALoCoQnvTMXdoX/bfxAQrUtrFXJ58D6bEqrIJovuTZ5C/Xp4g+1IgAsAE/IWJuSFuI3QOiLpupu7 X-Received: by 10.66.254.33 with SMTP id af1mr40951104pad.106.1422339459404; Mon, 26 Jan 2015 22:17:39 -0800 (PST) Received: from mew.localdomain (c-76-104-211-44.hsd1.wa.comcast.net. [76.104.211.44]) by mx.google.com with ESMTPSA id v8sm337107pdp.94.2015.01.26.22.17.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Jan 2015 22:17:38 -0800 (PST) From: Omar Sandoval To: Alexander Viro , Christoph Hellwig , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Omar Sandoval Subject: [PATCH] posix_acl: fix reference leaks in posix_acl_create Date: Mon, 26 Jan 2015 22:16:53 -0800 Message-Id: <0d8672e771b8fc1fef94db4b40b418afc8763c2b.1422338890.git.osandov@osandov.com> X-Mailer: git-send-email 2.2.2 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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=ham 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 get_acl gets a reference which we must release in the error cases. Signed-off-by: Omar Sandoval --- fs/posix_acl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/posix_acl.c b/fs/posix_acl.c index 0855f77..f8f3cc2 100644 --- a/fs/posix_acl.c +++ b/fs/posix_acl.c @@ -555,28 +555,31 @@ posix_acl_create(struct inode *dir, umode_t *mode, p = get_acl(dir, ACL_TYPE_DEFAULT); if (IS_ERR(p)) { if (p == ERR_PTR(-EOPNOTSUPP)) goto apply_umask; return PTR_ERR(p); } if (!p) goto apply_umask; *acl = posix_acl_clone(p, GFP_NOFS); - if (!*acl) + if (!*acl) { + posix_acl_release(p); return -ENOMEM; + } ret = posix_acl_create_masq(*acl, mode); if (ret < 0) { posix_acl_release(*acl); + posix_acl_release(p); return -ENOMEM; } if (ret == 0) { posix_acl_release(*acl); *acl = NULL; } if (!S_ISDIR(*mode)) { posix_acl_release(p); *default_acl = NULL;