cifs: Clean up an error code in cifs_root_iget()
Subsystems (3)
PATCH 1/1 cifs: Clean up an error code in cifs_root_iget()
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.
--- fs/cifs/inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/cifs/inode.c +3 -1
@@ -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; }
Signature · 1 line
2.17.1
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;
}Quoted 40 lines · Dan Carpenter via samba-technical
This patch silences a Smatch warning:
fs/cifs/inode.c:1094cifs_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-EOPNOTSUPPwhen we have the UNIX extensions. From the patch description in commitb5b374eab11e("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. Thiscifs_root_iget()function is only called fromcifs_read_super()and if we return NULL that causesd_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 <[email protected]>--- fs/cifs/inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)fs/cifs/inode.c +3
-2@@ -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; } --
Quoted 3 lines
2.17.1
--
Thanks,
Steve
Quoted 4 lines · Steve French
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