[PATCH 2/2] fs/ntfs3: Fix missing type checking in ntfs_get_acl_ex

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add default path for type checking. Comment says that this is checked
above, but for fast eyes I do not find it. We have this check also in
ntfs_set_acl_ex() so let's be consistent. Also other fs driver had
implemented default path. Some are even throwing BUG(), but that feels
little too harsh.

Fixes: be71b5cba2e6 ("fs/ntfs3: Add attrib operations")
Signed-off-by: Kari Argillander <kari.argillander@xxxxxxxxx>
---
 fs/ntfs3/xattr.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
index 944557d3a769..5e86bea7e0ab 100644
--- a/fs/ntfs3/xattr.c
+++ b/fs/ntfs3/xattr.c
@@ -498,20 +498,24 @@ static struct posix_acl *ntfs_get_acl_ex(struct user_namespace *mnt_userns,
 	int err;
 	void *buf;
 
-	/* allocate PATH_MAX bytes */
-	buf = __getname();
-	if (!buf)
-		return ERR_PTR(-ENOMEM);
-
-	/* Possible values of 'type' was already checked above */
-	if (type == ACL_TYPE_ACCESS) {
+	switch (type) {
+	case ACL_TYPE_ACCESS:
 		name = XATTR_NAME_POSIX_ACL_ACCESS;
 		name_len = sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1;
-	} else {
+		break;
+	case ACL_TYPE_DEFAULT:
 		name = XATTR_NAME_POSIX_ACL_DEFAULT;
 		name_len = sizeof(XATTR_NAME_POSIX_ACL_DEFAULT) - 1;
+		break;
+	default:
+		return ERR_PTR(-EINVAL);
 	}
 
+	/* allocate PATH_MAX bytes */
+	buf = __getname();
+	if (!buf)
+		return ERR_PTR(-ENOMEM);
+
 	if (!locked)
 		ni_lock(ni);
 
-- 
2.25.1





[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux