From patchwork Tue Nov 9 14:35:02 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shirish Pargaonkar X-Patchwork-Id: 311312 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oA9EeK41030136 for ; Tue, 9 Nov 2010 14:40:20 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753363Ab0KIOkT (ORCPT ); Tue, 9 Nov 2010 09:40:19 -0500 Received: from mail-px0-f174.google.com ([209.85.212.174]:62366 "EHLO mail-px0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752278Ab0KIOkS (ORCPT ); Tue, 9 Nov 2010 09:40:18 -0500 Received: by pxi15 with SMTP id 15so1247921pxi.19 for ; Tue, 09 Nov 2010 06:40:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=7nNpAi58Lde0E+iYanriR+t/BHVyjixHyieiZJC/Cog=; b=hGcMBTcGALN/yN5ZP3kWbWr7+7kwATJ27EnXAhMnBEUiYG/Ow8zCnQMcsHFNVhyPAZ H4boKUNXpywFO70deIv+iCjRSfwejrTQwa1D3IQkkCqSMbOwLtCEaXwwjead+BrCcmnM PSrytJnhjMgkiMMOzrt8ukcOrFWYOEcPIZMdE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=oC57+B1Yt5jC/4z+j+zRWFkunK/N3Cd0/lth9pnRfbULznnkwUA++Uya4yF+f3xT4w GHOrIKE/JkEXg+CDs6566m5jGWelLXsTePR/o1on6IzUMiuUJieQ1QErLVa4Caau0u5L WSL9NzAzc0i3gziPv5QECkaZTtMkmnWp2SqDk= Received: by 10.143.7.6 with SMTP id k6mr5837158wfi.347.1289313618472; Tue, 09 Nov 2010 06:40:18 -0800 (PST) Received: from localhost ([32.97.110.58]) by mx.google.com with ESMTPS id i2sm356744vcs.33.2010.11.09.06.40.16 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 09 Nov 2010 06:40:17 -0800 (PST) From: shirishpargaonkar@gmail.com To: smfrench@gmail.com, linux-cifs@vger.kernel.org Cc: Shirish Pargaonkar Subject: [PATCH] cifs: Percolate error up to the caller during get/set acls Date: Tue, 9 Nov 2010 08:35:02 -0600 Message-Id: <1289313302-31064-1-git-send-email-shirishpargaonkar@gmail.com> X-Mailer: git-send-email 1.6.0.2 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 09 Nov 2010 14:40:20 +0000 (UTC) diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index c9b4792..003588a 100644 --- a/fs/cifs/cifsacl.c +++ b/fs/cifs/cifsacl.c @@ -568,8 +568,11 @@ static struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb, cifs_put_tlink(tlink); - cFYI(1, "GetCIFSACL rc = %d ACL len %d", rc, *pacllen); - return pntsd; + cFYI(1, "%s: rc = %d ACL len %d", __func__, rc, *pacllen); + if (rc) + return ERR_PTR(rc); + else + return pntsd; } static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, @@ -591,19 +594,19 @@ static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, rc = CIFSSMBOpen(xid, tcon, path, FILE_OPEN, READ_CONTROL, 0, &fid, &oplock, NULL, cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); - if (rc) { - cERROR(1, "Unable to open file to get ACL"); - goto out; + if (!rc) { + rc = CIFSSMBGetCIFSACL(xid, tcon, fid, &pntsd, pacllen); + CIFSSMBClose(xid, tcon, fid); } - rc = CIFSSMBGetCIFSACL(xid, tcon, fid, &pntsd, pacllen); - cFYI(1, "GetCIFSACL rc = %d ACL len %d", rc, *pacllen); - - CIFSSMBClose(xid, tcon, fid); - out: cifs_put_tlink(tlink); FreeXid(xid); - return pntsd; + + cFYI(1, "%s: rc = %d ACL len %d", __func__, rc, *pacllen); + if (rc) + return ERR_PTR(rc); + else + return pntsd; } /* Retrieve an ACL from the server */ @@ -711,12 +714,18 @@ cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr, pntsd = get_cifs_acl(cifs_sb, inode, path, &acllen); /* if we can retrieve the ACL, now parse Access Control Entries, ACEs */ - if (pntsd) + if (!pntsd) + cERROR(1, "%s: NULL sec desc", __func__); + else if (IS_ERR(pntsd)) { + rc = PTR_ERR(pntsd); + cERROR(1, "%s: error %d getting sec desc", __func__, rc); + } else { rc = parse_sec_desc(pntsd, acllen, fattr); - if (rc) - cFYI(1, "parse sec desc failed rc = %d", rc); + kfree(pntsd); + if (rc) + cERROR(1, "parse sec desc failed rc = %d", rc); + } - kfree(pntsd); return; } @@ -736,7 +745,12 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode) /* Add three ACEs for owner, group, everyone getting rid of other ACEs as chmod disables ACEs and set the security descriptor */ - if (pntsd) { + if (!pntsd) + cERROR(1, "%s: NULL sec desc", __func__); + else 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 */