All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] fs/ntfs3: Fix minor things in ntfs_get_acl_ex()
@ 2021-08-26  8:35 Kari Argillander
  2021-08-26  8:35 ` [PATCH 1/2] fs/ntfs3: Fix pass zero to ERR_PTR() in ntfs_get_acl_ex Kari Argillander
  2021-08-26  8:35 ` [PATCH 2/2] fs/ntfs3: Fix missing type checking " Kari Argillander
  0 siblings, 2 replies; 4+ messages in thread
From: Kari Argillander @ 2021-08-26  8:35 UTC (permalink / raw)
  To: Konstantin Komarov, ntfs3; +Cc: Kari Argillander

First patch fix Smatch warning.

Second one add missing default path. This is not necessarylly needed,
but will not make any harm and other filesystems have it and it is also
checked some places in ntfs3. So let's be consistent.

Kari Argillander (2):
  fs/ntfs3: Fix pass zero to ERR_PTR() in ntfs_get_acl_ex
  fs/ntfs3: Fix missing type checking in ntfs_get_acl_ex

 fs/ntfs3/xattr.c | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] fs/ntfs3: Fix pass zero to ERR_PTR() in ntfs_get_acl_ex
  2021-08-26  8:35 [PATCH 0/2] fs/ntfs3: Fix minor things in ntfs_get_acl_ex() Kari Argillander
@ 2021-08-26  8:35 ` Kari Argillander
  2021-08-26  9:13   ` Kari Argillander
  2021-08-26  8:35 ` [PATCH 2/2] fs/ntfs3: Fix missing type checking " Kari Argillander
  1 sibling, 1 reply; 4+ messages in thread
From: Kari Argillander @ 2021-08-26  8:35 UTC (permalink / raw)
  To: Konstantin Komarov, ntfs3; +Cc: Kari Argillander

Fix smatch warning:
	fs/ntfs3/xattr.c:529 ntfs_get_acl_ex()
	warn: passing zero to 'ERR_PTR'

Fixes: be71b5cba2e6 ("fs/ntfs3: Add attrib operations")
Signed-off-by: Kari Argillander <kari.argillander@gmail.com>
---
 fs/ntfs3/xattr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
index 98871c895e77..944557d3a769 100644
--- a/fs/ntfs3/xattr.c
+++ b/fs/ntfs3/xattr.c
@@ -525,8 +525,10 @@ static struct posix_acl *ntfs_get_acl_ex(struct user_namespace *mnt_userns,
 		acl = posix_acl_from_xattr(mnt_userns, buf, err);
 		if (!IS_ERR(acl))
 			set_cached_acl(inode, type, acl);
+	} else if (!err || err == -ENODATA) {
+		acl = NULL;
 	} else {
-		acl = err == -ENODATA ? NULL : ERR_PTR(err);
+		acl = ERR_PTR(err);
 	}
 
 	__putname(buf);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] fs/ntfs3: Fix missing type checking in ntfs_get_acl_ex
  2021-08-26  8:35 [PATCH 0/2] fs/ntfs3: Fix minor things in ntfs_get_acl_ex() Kari Argillander
  2021-08-26  8:35 ` [PATCH 1/2] fs/ntfs3: Fix pass zero to ERR_PTR() in ntfs_get_acl_ex Kari Argillander
@ 2021-08-26  8:35 ` Kari Argillander
  1 sibling, 0 replies; 4+ messages in thread
From: Kari Argillander @ 2021-08-26  8:35 UTC (permalink / raw)
  To: Konstantin Komarov, ntfs3; +Cc: Kari Argillander

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@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] fs/ntfs3: Fix pass zero to ERR_PTR() in ntfs_get_acl_ex
  2021-08-26  8:35 ` [PATCH 1/2] fs/ntfs3: Fix pass zero to ERR_PTR() in ntfs_get_acl_ex Kari Argillander
@ 2021-08-26  9:13   ` Kari Argillander
  0 siblings, 0 replies; 4+ messages in thread
From: Kari Argillander @ 2021-08-26  9:13 UTC (permalink / raw)
  To: Konstantin Komarov, ntfs3

On Thu, Aug 26, 2021 at 11:35:48AM +0300, Kari Argillander wrote:
> Fix smatch warning:
> 	fs/ntfs3/xattr.c:529 ntfs_get_acl_ex()
> 	warn: passing zero to 'ERR_PTR'
> 
> Fixes: be71b5cba2e6 ("fs/ntfs3: Add attrib operations")
> Signed-off-by: Kari Argillander <kari.argillander@gmail.com>
> ---
>  fs/ntfs3/xattr.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
> index 98871c895e77..944557d3a769 100644
> --- a/fs/ntfs3/xattr.c
> +++ b/fs/ntfs3/xattr.c
> @@ -525,8 +525,10 @@ static struct posix_acl *ntfs_get_acl_ex(struct user_namespace *mnt_userns,
>  		acl = posix_acl_from_xattr(mnt_userns, buf, err);
>  		if (!IS_ERR(acl))
>  			set_cached_acl(inode, type, acl);
> +	} else if (!err || err == -ENODATA) {
> +		acl = NULL;
>  	} else {
> -		acl = err == -ENODATA ? NULL : ERR_PTR(err);
> +		acl = ERR_PTR(err);
>  	}
>  
>  	__putname(buf);

I just notice that this is same as Dan already has sended:
https://lore.kernel.org/ntfs3/20210824114858.GH31143@kili/

You can choose if you prefer this or that. Sorry for double patch.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-08-26  9:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-26  8:35 [PATCH 0/2] fs/ntfs3: Fix minor things in ntfs_get_acl_ex() Kari Argillander
2021-08-26  8:35 ` [PATCH 1/2] fs/ntfs3: Fix pass zero to ERR_PTR() in ntfs_get_acl_ex Kari Argillander
2021-08-26  9:13   ` Kari Argillander
2021-08-26  8:35 ` [PATCH 2/2] fs/ntfs3: Fix missing type checking " Kari Argillander

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.