All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Steve French <sfrench@samba.org>
Cc: linux-cifs@vger.kernel.org, samba-technical@lists.samba.org,
	kernel-janitors@vger.kernel.org
Subject: [PATCH] cifs: Clean up an error code in cifs_root_iget()
Date: Thu, 28 Feb 2019 08:26:59 +0300	[thread overview]
Message-ID: <20190228052659.GA3253@kadam> (raw)

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


WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Steve French <sfrench@samba.org>
Cc: linux-cifs@vger.kernel.org, samba-technical@lists.samba.org,
	kernel-janitors@vger.kernel.org
Subject: [PATCH] cifs: Clean up an error code in cifs_root_iget()
Date: Thu, 28 Feb 2019 05:26:59 +0000	[thread overview]
Message-ID: <20190228052659.GA3253@kadam> (raw)

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

             reply	other threads:[~2019-02-28  5:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-28  5:26 Dan Carpenter [this message]
2019-02-28  5:26 ` [PATCH] cifs: Clean up an error code in cifs_root_iget() 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190228052659.GA3253@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=samba-technical@lists.samba.org \
    --cc=sfrench@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.