linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv2 06/12]posix_acl: Add the check items
@ 2009-12-21 11:58 Liuwenyi
  0 siblings, 0 replies; only message in thread
From: Liuwenyi @ 2009-12-21 11:58 UTC (permalink / raw)
  To: viro, hch, linux-fsdevel, linux-kernel, strongzgy, onlyflyer

move the ACL validation check in to fs/posix_acl.c.
Including nullpointer check and PTR_ERR check.

---
Signed-off-by: Liuwenyi <qingshenlwy@gmail.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org

---
diff --git a/fs/generic_acl.c b/fs/generic_acl.c
index 5545803..5d88218 100644
--- a/fs/generic_acl.c
+++ b/fs/generic_acl.c
@@ -68,6 +68,7 @@ generic_acl_set(struct dentry *dentry, const char
*name, const void *value,
struct inode *inode = dentry->d_inode;
struct posix_acl *acl = NULL;
int error;
+ mode_t mode;

if (strcmp(name, "") != 0)
return -EINVAL;
@@ -80,32 +81,31 @@ generic_acl_set(struct dentry *dentry, const char
*name, const void *value,
if (IS_ERR(acl))
return PTR_ERR(acl);
}
- if (acl) {
- mode_t mode;

- error = posix_acl_valid(acl);
- if (error)
+ error = posix_acl_valid(acl);
+ if (error)
+ goto failed;
+
+ switch (type) {
+ case ACL_TYPE_ACCESS:
+ mode = inode->i_mode;
+ error = posix_acl_equiv_mode(acl, &mode);
+ if (error < 0)
goto failed;
- switch (type) {
- case ACL_TYPE_ACCESS:
- mode = inode->i_mode;
- error = posix_acl_equiv_mode(acl, &mode);
- if (error < 0)
- goto failed;
- inode->i_mode = mode;
- if (error == 0) {
- posix_acl_release(acl);
- acl = NULL;
- }
- break;
- case ACL_TYPE_DEFAULT:
- if (!S_ISDIR(inode->i_mode)) {
- error = -EINVAL;
- goto failed;
- }
- break;
+ inode->i_mode = mode;
+ if (error == 0) {
+ posix_acl_release(acl);
+ acl = NULL;
}
+ break;
+ case ACL_TYPE_DEFAULT:
+ if (!S_ISDIR(inode->i_mode)) {
+ error = -EINVAL;
+ goto failed;
+ }
+ break;
}
+
set_cached_acl(inode, type, acl);
error = 0;
failed:

-- 
Best Regards,
Liuwenyi

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2009-12-21 11:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-21 11:58 [PATCHv2 06/12]posix_acl: Add the check items Liuwenyi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).