diff options
author | Eric Van Hensbergen <ericvh@gmail.com> | 2010-02-08 17:23:23 -0500 |
---|---|---|
committer | Eric Van Hensbergen <ericvh@gmail.com> | 2010-02-08 17:23:23 -0500 |
commit | d8c8a9e36560e9ff4c99279d64ce5dd0e1a33fa6 (patch) | |
tree | b52f301bd5811b9b813b6d244b555edbab38299a /net/9p/client.c | |
parent | 7a4439c406c21b1e900ed497cec1a79d05b38c07 (diff) |
9p: fix option parsing
Options pointer is being moved before calling kfree() which seems
to cause problems. This uses a separate pointer to track and free
original allocation.
Signed-off-by: Venkateswararao Jujjuri <jvrao@us.ibm.com>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>w
Diffstat (limited to 'net/9p/client.c')
-rw-r--r-- | net/9p/client.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/net/9p/client.c b/net/9p/client.c index a2e2d61b903..cbe066966b3 100644 --- a/net/9p/client.c +++ b/net/9p/client.c | |||
@@ -69,7 +69,7 @@ p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...); | |||
69 | 69 | ||
70 | static int parse_opts(char *opts, struct p9_client *clnt) | 70 | static int parse_opts(char *opts, struct p9_client *clnt) |
71 | { | 71 | { |
72 | char *options; | 72 | char *options, *tmp_options; |
73 | char *p; | 73 | char *p; |
74 | substring_t args[MAX_OPT_ARGS]; | 74 | substring_t args[MAX_OPT_ARGS]; |
75 | int option; | 75 | int option; |
@@ -81,12 +81,13 @@ static int parse_opts(char *opts, struct p9_client *clnt) | |||
81 | if (!opts) | 81 | if (!opts) |
82 | return 0; | 82 | return 0; |
83 | 83 | ||
84 | options = kstrdup(opts, GFP_KERNEL); | 84 | tmp_options = kstrdup(opts, GFP_KERNEL); |
85 | if (!options) { | 85 | if (!tmp_options) { |
86 | P9_DPRINTK(P9_DEBUG_ERROR, | 86 | P9_DPRINTK(P9_DEBUG_ERROR, |
87 | "failed to allocate copy of option string\n"); | 87 | "failed to allocate copy of option string\n"); |
88 | return -ENOMEM; | 88 | return -ENOMEM; |
89 | } | 89 | } |
90 | options = tmp_options; | ||
90 | 91 | ||
91 | while ((p = strsep(&options, ",")) != NULL) { | 92 | while ((p = strsep(&options, ",")) != NULL) { |
92 | int token; | 93 | int token; |
@@ -125,7 +126,7 @@ static int parse_opts(char *opts, struct p9_client *clnt) | |||
125 | } | 126 | } |
126 | 127 | ||
127 | free_and_return: | 128 | free_and_return: |
128 | kfree(options); | 129 | kfree(tmp_options); |
129 | return ret; | 130 | return ret; |
130 | } | 131 | } |
131 | 132 | ||