From patchwork Tue Oct 16 11:26:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1600221 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 502B140ABA for ; Tue, 16 Oct 2012 11:26:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754186Ab2JPL0y (ORCPT ); Tue, 16 Oct 2012 07:26:54 -0400 Received: from mail-yh0-f46.google.com ([209.85.213.46]:56655 "EHLO mail-yh0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753916Ab2JPL0x (ORCPT ); Tue, 16 Oct 2012 07:26:53 -0400 Received: by mail-yh0-f46.google.com with SMTP id m54so1543080yhm.19 for ; Tue, 16 Oct 2012 04:26:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=N5FQ2jDQeT7qK1mypWoFQFTSPGyCh2MGiaUDICSR+Qk=; b=YgpZ0IxfatxHGJcnmVxs0JFkUP4ZtUaleGmBZLxMD8d3MZcU9+NJG+r/r1Ofxj9dNg DMvveh+Njm9QqYZH0+kpRxLStrw/TIlMjKP7LVee1y3gX52yUcemUmy6fOjnrAHNUjNA QpzGdgTDrmb76qJMtuEj2sXoP847OXreUSt3nnd7dLgkkvprHKmG/WYZud8kRhozNzeO 9FyY1obilppWDx7KC1UALW+pfDUPCnouIkg4A+TQMTDoXwPkrH7T3OMnsJsPD/QkwFHU 3Y3dDWSYW3ezUUdUuN/IJ7wiaBGpl9pHXCCfd4pnz+91KxeAZY4pffACjp1Juk6K125c ziPg== Received: by 10.236.181.35 with SMTP id k23mr5693575yhm.99.1350386812778; Tue, 16 Oct 2012 04:26:52 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-107-015-110-129.nc.res.rr.com. [107.15.110.129]) by mx.google.com with ESMTPS id o12sm15888943anp.8.2012.10.16.04.26.51 (version=SSLv3 cipher=OTHER); Tue, 16 Oct 2012 04:26:52 -0700 (PDT) From: Jeff Layton To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org Subject: [PATCH 1/4] cifs: clean up id_mode_to_cifs_acl Date: Tue, 16 Oct 2012 07:26:43 -0400 Message-Id: <1350386806-18356-2-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1350386806-18356-1-git-send-email-jlayton@redhat.com> References: <1350386806-18356-1-git-send-email-jlayton@redhat.com> X-Gm-Message-State: ALoCoQnaFf9voFFo3vOqgacsd038kBmVP68Da0DcjcxpoKSDdFZzohukOpIPGrYgRrnRaNcWhGOW Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Add a label we can goto on error, and get rid of some excess indentation. Also move to kernel-style comments. Signed-off-by: Jeff Layton Reviewed-by: Shirish Pargaonkar --- fs/cifs/cifsacl.c | 53 +++++++++++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index 0955d23..d0b2bfb 100644 --- a/fs/cifs/cifsacl.c +++ b/fs/cifs/cifsacl.c @@ -1307,42 +1307,39 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 nmode, /* Get the security descriptor */ pntsd = get_cifs_acl(CIFS_SB(inode->i_sb), inode, path, &secdesclen); - - /* Add three ACEs for owner, group, everyone getting rid of - other ACEs as chmod disables ACEs and set the security descriptor */ - if (IS_ERR(pntsd)) { rc = PTR_ERR(pntsd); cERROR(1, "%s: error %d getting sec desc", __func__, rc); - } else { - /* allocate memory for the smb header, - set security descriptor request security descriptor - parameters, and secuirty descriptor itself */ - - secdesclen = secdesclen < DEFSECDESCLEN ? - DEFSECDESCLEN : secdesclen; - pnntsd = kmalloc(secdesclen, GFP_KERNEL); - if (!pnntsd) { - cERROR(1, "Unable to allocate security descriptor"); - kfree(pntsd); - return -ENOMEM; - } + goto out; + } - rc = build_sec_desc(pntsd, pnntsd, secdesclen, nmode, uid, gid, - &aclflag); + /* + * Add three ACEs for owner, group, everyone getting rid of other ACEs + * as chmod disables ACEs and set the security descriptor allocate + * memory for the smb header, set security descriptor request security + * descriptor parameters, and secuirty descriptor itself + */ + secdesclen = max_t(u32, secdesclen, DEFSECDESCLEN); + pnntsd = kmalloc(secdesclen, GFP_KERNEL); + if (!pnntsd) { + cERROR(1, "Unable to allocate security descriptor"); + kfree(pntsd); + return -ENOMEM; + } - cFYI(DBG2, "build_sec_desc rc: %d", rc); + rc = build_sec_desc(pntsd, pnntsd, secdesclen, nmode, uid, gid, + &aclflag); - if (!rc) { - /* Set the security descriptor */ - rc = set_cifs_acl(pnntsd, secdesclen, inode, - path, aclflag); - cFYI(DBG2, "set_cifs_acl rc: %d", rc); - } + cFYI(DBG2, "build_sec_desc rc: %d", rc); - kfree(pnntsd); - kfree(pntsd); + if (!rc) { + /* Set the security descriptor */ + rc = set_cifs_acl(pnntsd, secdesclen, inode, path, aclflag); + cFYI(DBG2, "set_cifs_acl rc: %d", rc); } + kfree(pnntsd); + kfree(pntsd); +out: return rc; }