* [PATCH] cifs: Clean up an error code in cifs_root_iget()
@ 2019-02-28 5:26 ` Dan Carpenter
0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2019-02-28 5:26 UTC (permalink / raw)
To: Steve French; +Cc: linux-cifs, samba-technical, kernel-janitors
This patch silences a Smatch warning:
fs/cifs/inode.c:1094 cifs_root_iget() warn: passing zero to 'ERR_PTR'
The shouldn't have a noticeable effect on runtime, it's basically
a cleanup. The code is checking to ensure that cifs_get_inode_info_unix()
returns -EOPNOTSUPP when we have the UNIX extensions. From the patch
description in commit b5b374eab11e ("Workaround Mac server problem")
this affects Macs.
Presumably most of the time "rc" is zero, which means we return
ERR_PTR(0) which is NULL. This cifs_root_iget() function is only called
from cifs_read_super() and if we return NULL that causes d_make_root()
to return NULL so in the end we fail with -ENOMEM.
After this patch is applied we instead return with -EINVAL.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
fs/cifs/inode.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 0f53ecb071ac..e40c554bb2f3 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -1080,8 +1080,10 @@ struct inode *cifs_root_iget(struct super_block *sb)
if (tcon->unix_ext) {
rc = cifs_get_inode_info_unix(&inode, path, sb, xid);
/* some servers mistakenly claim POSIX support */
- if (rc != -EOPNOTSUPP)
+ if (rc != -EOPNOTSUPP) {
+ rc = -EINVAL;
goto iget_no_retry;
+ }
cifs_dbg(VFS, "server does not support POSIX extensions");
tcon->unix_ext = false;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH] cifs: Clean up an error code in cifs_root_iget()
@ 2019-02-28 5:26 ` Dan Carpenter
0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2019-02-28 5:26 UTC (permalink / raw)
To: Steve French; +Cc: linux-cifs, samba-technical, kernel-janitors
This patch silences a Smatch warning:
fs/cifs/inode.c:1094 cifs_root_iget() warn: passing zero to 'ERR_PTR'
The shouldn't have a noticeable effect on runtime, it's basically
a cleanup. The code is checking to ensure that cifs_get_inode_info_unix()
returns -EOPNOTSUPP when we have the UNIX extensions. From the patch
description in commit b5b374eab11e ("Workaround Mac server problem")
this affects Macs.
Presumably most of the time "rc" is zero, which means we return
ERR_PTR(0) which is NULL. This cifs_root_iget() function is only called
from cifs_read_super() and if we return NULL that causes d_make_root()
to return NULL so in the end we fail with -ENOMEM.
After this patch is applied we instead return with -EINVAL.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
fs/cifs/inode.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 0f53ecb071ac..e40c554bb2f3 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -1080,8 +1080,10 @@ struct inode *cifs_root_iget(struct super_block *sb)
if (tcon->unix_ext) {
rc = cifs_get_inode_info_unix(&inode, path, sb, xid);
/* some servers mistakenly claim POSIX support */
- if (rc != -EOPNOTSUPP)
+ if (rc != -EOPNOTSUPP) {
+ rc = -EINVAL;
goto iget_no_retry;
+ }
cifs_dbg(VFS, "server does not support POSIX extensions");
tcon->unix_ext = false;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] cifs: Clean up an error code in cifs_root_iget()
2019-02-28 5:26 ` Dan Carpenter
@ 2019-02-28 5:44 ` Steve French
-1 siblings, 0 replies; 6+ messages in thread
From: Steve French @ 2019-02-28 5:44 UTC (permalink / raw)
To: Dan Carpenter; +Cc: Steve French, CIFS, kernel-janitors, samba-technical
Won't that change behavior and cause the success case (server returned
0, and does support POSIX and &inode pointer is ok) to now return
-EINVAL.
Before if rc was 0 and inode was filled in we wouldn't execute this else block:
} else if (rc) {
iget_failed(inode);
inode = ERR_PTR(rc);
}
But with your change, won't we return EINVAL for the success case?
How about just changing:
iget_no_retry:
if (!inode) {
inode = ERR_PTR(rc);
goto out;
}
to
iget_no_retry:
if (!inode) {
if (rc = 0)
rc = -EINVAL;
inode = ERR_PTR(rc);
goto out;
}
On Wed, Feb 27, 2019 at 11:28 PM Dan Carpenter via samba-technical
<samba-technical@lists.samba.org> wrote:
>
> This patch silences a Smatch warning:
>
> fs/cifs/inode.c:1094 cifs_root_iget() warn: passing zero to 'ERR_PTR'
>
> The shouldn't have a noticeable effect on runtime, it's basically
> a cleanup. The code is checking to ensure that cifs_get_inode_info_unix()
> returns -EOPNOTSUPP when we have the UNIX extensions. From the patch
> description in commit b5b374eab11e ("Workaround Mac server problem")
> this affects Macs.
>
> Presumably most of the time "rc" is zero, which means we return
> ERR_PTR(0) which is NULL. This cifs_root_iget() function is only called
> from cifs_read_super() and if we return NULL that causes d_make_root()
> to return NULL so in the end we fail with -ENOMEM.
>
> After this patch is applied we instead return with -EINVAL.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> fs/cifs/inode.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
> index 0f53ecb071ac..e40c554bb2f3 100644
> --- a/fs/cifs/inode.c
> +++ b/fs/cifs/inode.c
> @@ -1080,8 +1080,10 @@ struct inode *cifs_root_iget(struct super_block *sb)
> if (tcon->unix_ext) {
> rc = cifs_get_inode_info_unix(&inode, path, sb, xid);
> /* some servers mistakenly claim POSIX support */
> - if (rc != -EOPNOTSUPP)
> + if (rc != -EOPNOTSUPP) {
> + rc = -EINVAL;
> goto iget_no_retry;
> + }
> cifs_dbg(VFS, "server does not support POSIX extensions");
> tcon->unix_ext = false;
> }
> --
> 2.17.1
>
>
--
Thanks,
Steve
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] cifs: Clean up an error code in cifs_root_iget()
@ 2019-02-28 5:44 ` Steve French
0 siblings, 0 replies; 6+ messages in thread
From: Steve French @ 2019-02-28 5:44 UTC (permalink / raw)
To: Dan Carpenter; +Cc: Steve French, CIFS, kernel-janitors, samba-technical
Won't that change behavior and cause the success case (server returned
0, and does support POSIX and &inode pointer is ok) to now return
-EINVAL.
Before if rc was 0 and inode was filled in we wouldn't execute this else block:
} else if (rc) {
iget_failed(inode);
inode = ERR_PTR(rc);
}
But with your change, won't we return EINVAL for the success case?
How about just changing:
iget_no_retry:
if (!inode) {
inode = ERR_PTR(rc);
goto out;
}
to
iget_no_retry:
if (!inode) {
if (rc == 0)
rc = -EINVAL;
inode = ERR_PTR(rc);
goto out;
}
On Wed, Feb 27, 2019 at 11:28 PM Dan Carpenter via samba-technical
<samba-technical@lists.samba.org> wrote:
>
> This patch silences a Smatch warning:
>
> fs/cifs/inode.c:1094 cifs_root_iget() warn: passing zero to 'ERR_PTR'
>
> The shouldn't have a noticeable effect on runtime, it's basically
> a cleanup. The code is checking to ensure that cifs_get_inode_info_unix()
> returns -EOPNOTSUPP when we have the UNIX extensions. From the patch
> description in commit b5b374eab11e ("Workaround Mac server problem")
> this affects Macs.
>
> Presumably most of the time "rc" is zero, which means we return
> ERR_PTR(0) which is NULL. This cifs_root_iget() function is only called
> from cifs_read_super() and if we return NULL that causes d_make_root()
> to return NULL so in the end we fail with -ENOMEM.
>
> After this patch is applied we instead return with -EINVAL.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> fs/cifs/inode.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
> index 0f53ecb071ac..e40c554bb2f3 100644
> --- a/fs/cifs/inode.c
> +++ b/fs/cifs/inode.c
> @@ -1080,8 +1080,10 @@ struct inode *cifs_root_iget(struct super_block *sb)
> if (tcon->unix_ext) {
> rc = cifs_get_inode_info_unix(&inode, path, sb, xid);
> /* some servers mistakenly claim POSIX support */
> - if (rc != -EOPNOTSUPP)
> + if (rc != -EOPNOTSUPP) {
> + rc = -EINVAL;
> goto iget_no_retry;
> + }
> cifs_dbg(VFS, "server does not support POSIX extensions");
> tcon->unix_ext = false;
> }
> --
> 2.17.1
>
>
--
Thanks,
Steve
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] cifs: Clean up an error code in cifs_root_iget()
2019-02-28 5:44 ` Steve French
@ 2019-02-28 13:34 ` Dan Carpenter
-1 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2019-02-28 13:34 UTC (permalink / raw)
To: Steve French; +Cc: Steve French, CIFS, kernel-janitors, samba-technical
On Wed, Feb 27, 2019 at 11:44:14PM -0600, Steve French wrote:
> Won't that change behavior and cause the success case (server returned
> 0, and does support POSIX and &inode pointer is ok) to now return
> -EINVAL.
>
You're right. I'm really sorry. I don't know why I misread the code...
Also looking at it now, this was a false positive in Smatch. I have
been working on that code in the past couple days and I don't have the
warning in my latest build.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] cifs: Clean up an error code in cifs_root_iget()
@ 2019-02-28 13:34 ` Dan Carpenter
0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2019-02-28 13:34 UTC (permalink / raw)
To: Steve French; +Cc: Steve French, CIFS, kernel-janitors, samba-technical
On Wed, Feb 27, 2019 at 11:44:14PM -0600, Steve French wrote:
> Won't that change behavior and cause the success case (server returned
> 0, and does support POSIX and &inode pointer is ok) to now return
> -EINVAL.
>
You're right. I'm really sorry. I don't know why I misread the code...
Also looking at it now, this was a false positive in Smatch. I have
been working on that code in the past couple days and I don't have the
warning in my latest build.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-02-28 13:35 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-28 5:26 [PATCH] cifs: Clean up an error code in cifs_root_iget() Dan Carpenter
2019-02-28 5:26 ` Dan Carpenter
2019-02-28 5:44 ` Steve French
2019-02-28 5:44 ` Steve French
2019-02-28 13:34 ` Dan Carpenter
2019-02-28 13:34 ` Dan Carpenter
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.