From: Chengguang Xu <cgxu519@gmx.com>
To: akpm@linux-foundation.org, ericvh@gmail.com, rminnich@sandia.gov,
lucho@ionkov.net
Cc: v9fs-developer@lists.sourceforge.net,
linux-kernel@vger.kernel.org, Chengguang Xu <cgxu519@gmx.com>
Subject: [V9fs-developer][PATCH v3 2/2] fs/9p: detecting invalid options as much as possible
Date: Thu, 3 May 2018 17:44:36 +0800 [thread overview]
Message-ID: <1525340676-34072-2-git-send-email-cgxu519@gmx.com> (raw)
In-Reply-To: <1525340676-34072-1-git-send-email-cgxu519@gmx.com>
Currently when detecting invalid options in option parsing,
some options(e.g. msize) just set errno and allow to continuously
validate other options so that it can detect invalid options
as much as possible and give proper error messages together.
This patch applies same rule to option 'cache' and 'access'
when detecting -EINVAL.
Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
---
Changes since v2:
- Introduce a new temporary variable to avoid overriding error code.
- Delete redundant continue in error case.
Changes since v1:
- Do not change behavior when detecting ENOMEM or unrecognized options.
fs/9p/v9fs.c | 29 ++++++++++++-----------------
1 file changed, 12 insertions(+), 17 deletions(-)
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
index e622f0f..0429c8e 100644
--- a/fs/9p/v9fs.c
+++ b/fs/9p/v9fs.c
@@ -210,12 +210,12 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
p9_debug(P9_DEBUG_ERROR,
"integer field, but no integer?\n");
ret = r;
- continue;
- }
- v9ses->debug = option;
+ } else {
+ v9ses->debug = option;
#ifdef CONFIG_NET_9P_DEBUG
- p9_debug_level = option;
+ p9_debug_level = option;
#endif
+ }
break;
case Opt_dfltuid:
@@ -231,7 +231,6 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
p9_debug(P9_DEBUG_ERROR,
"uid field, but not a uid?\n");
ret = -EINVAL;
- continue;
}
break;
case Opt_dfltgid:
@@ -247,7 +246,6 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
p9_debug(P9_DEBUG_ERROR,
"gid field, but not a gid?\n");
ret = -EINVAL;
- continue;
}
break;
case Opt_afid:
@@ -256,9 +254,9 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
p9_debug(P9_DEBUG_ERROR,
"integer field, but no integer?\n");
ret = r;
- continue;
+ } else {
+ v9ses->afid = option;
}
- v9ses->afid = option;
break;
case Opt_uname:
kfree(v9ses->uname);
@@ -306,13 +304,12 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
"problem allocating copy of cache arg\n");
goto free_and_return;
}
- ret = get_cache_mode(s);
- if (ret == -EINVAL) {
- kfree(s);
- goto free_and_return;
- }
+ r = get_cache_mode(s);
+ if (r < 0)
+ ret = r;
+ else
+ v9ses->cache = r;
- v9ses->cache = ret;
kfree(s);
break;
@@ -341,14 +338,12 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
pr_info("Unknown access argument %s\n",
s);
kfree(s);
- goto free_and_return;
+ continue;
}
v9ses->uid = make_kuid(current_user_ns(), uid);
if (!uid_valid(v9ses->uid)) {
ret = -EINVAL;
pr_info("Uknown uid %s\n", s);
- kfree(s);
- goto free_and_return;
}
}
--
1.8.3.1
next prev parent reply other threads:[~2018-05-03 9:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-03 9:44 [V9fs-developer][PATCH v3 1/2] net/9p: " Chengguang Xu
2018-05-03 9:44 ` Chengguang Xu [this message]
2018-05-10 22:31 ` Andrew Morton
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=1525340676-34072-2-git-send-email-cgxu519@gmx.com \
--to=cgxu519@gmx.com \
--cc=akpm@linux-foundation.org \
--cc=ericvh@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lucho@ionkov.net \
--cc=rminnich@sandia.gov \
--cc=v9fs-developer@lists.sourceforge.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®