LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [V9fs-developer][PATCH v3 1/2] net/9p: detecting invalid options as much as possible
@ 2018-05-03 9:44 Chengguang Xu
2018-05-03 9:44 ` [V9fs-developer][PATCH v3 2/2] fs/9p: " Chengguang Xu
2018-05-10 22:31 ` [V9fs-developer][PATCH v3 1/2] net/9p: " Andrew Morton
0 siblings, 2 replies; 3+ messages in thread
From: Chengguang Xu @ 2018-05-03 9:44 UTC (permalink / raw)
To: akpm, ericvh, rminnich, lucho; +Cc: v9fs-developer, linux-kernel, Chengguang Xu
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 'trans' and 'version'
when detecting -EINVAL.
Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
---
Changes since v2:
- Introduce a new temporary variable to avoid overriding error code.
Changes since v1:
- Do not change behavior when detecting ENOMEM or unrecognized options.
net/9p/client.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/net/9p/client.c b/net/9p/client.c
index 21e6df1..18c5271 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -198,8 +198,6 @@ static int parse_opts(char *opts, struct p9_client *clnt)
pr_info("Could not find request transport: %s\n",
s);
ret = -EINVAL;
- kfree(s);
- goto free_and_return;
}
kfree(s);
break;
@@ -214,13 +212,12 @@ static int parse_opts(char *opts, struct p9_client *clnt)
"problem allocating copy of version arg\n");
goto free_and_return;
}
- ret = get_protocol_version(s);
- if (ret == -EINVAL) {
- kfree(s);
- goto free_and_return;
- }
+ r = get_protocol_version(s);
+ if (r < 0)
+ ret = r;
+ else
+ clnt->proto_version = r;
kfree(s);
- clnt->proto_version = ret;
break;
default:
continue;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [V9fs-developer][PATCH v3 2/2] fs/9p: detecting invalid options as much as possible
2018-05-03 9:44 [V9fs-developer][PATCH v3 1/2] net/9p: detecting invalid options as much as possible Chengguang Xu
@ 2018-05-03 9:44 ` Chengguang Xu
2018-05-10 22:31 ` [V9fs-developer][PATCH v3 1/2] net/9p: " Andrew Morton
1 sibling, 0 replies; 3+ messages in thread
From: Chengguang Xu @ 2018-05-03 9:44 UTC (permalink / raw)
To: akpm, ericvh, rminnich, lucho; +Cc: v9fs-developer, linux-kernel, Chengguang Xu
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [V9fs-developer][PATCH v3 1/2] net/9p: detecting invalid options as much as possible
2018-05-03 9:44 [V9fs-developer][PATCH v3 1/2] net/9p: detecting invalid options as much as possible Chengguang Xu
2018-05-03 9:44 ` [V9fs-developer][PATCH v3 2/2] fs/9p: " Chengguang Xu
@ 2018-05-10 22:31 ` Andrew Morton
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2018-05-10 22:31 UTC (permalink / raw)
To: Chengguang Xu; +Cc: ericvh, rminnich, lucho, v9fs-developer, linux-kernel
On Thu, 3 May 2018 17:44:35 +0800 Chengguang Xu <cgxu519@gmx.com> wrote:
> 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 'trans' and 'version'
> when detecting -EINVAL.
Looks OK.
It does mean that if two or more options cause errors, we will now
return the error code arising from the final error rather than from the
first error (or from some mish-mash mixture of both, as the present
code does). But I don't think this matters.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-05-10 22:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-03 9:44 [V9fs-developer][PATCH v3 1/2] net/9p: detecting invalid options as much as possible Chengguang Xu
2018-05-03 9:44 ` [V9fs-developer][PATCH v3 2/2] fs/9p: " Chengguang Xu
2018-05-10 22:31 ` [V9fs-developer][PATCH v3 1/2] net/9p: " Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).