You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
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
This commit is contained in:
+5
-4
@@ -69,7 +69,7 @@ p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...);
|
||||
|
||||
static int parse_opts(char *opts, struct p9_client *clnt)
|
||||
{
|
||||
char *options;
|
||||
char *options, *tmp_options;
|
||||
char *p;
|
||||
substring_t args[MAX_OPT_ARGS];
|
||||
int option;
|
||||
@@ -81,12 +81,13 @@ static int parse_opts(char *opts, struct p9_client *clnt)
|
||||
if (!opts)
|
||||
return 0;
|
||||
|
||||
options = kstrdup(opts, GFP_KERNEL);
|
||||
if (!options) {
|
||||
tmp_options = kstrdup(opts, GFP_KERNEL);
|
||||
if (!tmp_options) {
|
||||
P9_DPRINTK(P9_DEBUG_ERROR,
|
||||
"failed to allocate copy of option string\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
options = tmp_options;
|
||||
|
||||
while ((p = strsep(&options, ",")) != NULL) {
|
||||
int token;
|
||||
@@ -125,7 +126,7 @@ static int parse_opts(char *opts, struct p9_client *clnt)
|
||||
}
|
||||
|
||||
free_and_return:
|
||||
kfree(options);
|
||||
kfree(tmp_options);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
+6
-4
@@ -714,7 +714,7 @@ static int parse_opts(char *params, struct p9_fd_opts *opts)
|
||||
char *p;
|
||||
substring_t args[MAX_OPT_ARGS];
|
||||
int option;
|
||||
char *options;
|
||||
char *options, *tmp_options;
|
||||
int ret;
|
||||
|
||||
opts->port = P9_PORT;
|
||||
@@ -724,12 +724,13 @@ static int parse_opts(char *params, struct p9_fd_opts *opts)
|
||||
if (!params)
|
||||
return 0;
|
||||
|
||||
options = kstrdup(params, GFP_KERNEL);
|
||||
if (!options) {
|
||||
tmp_options = kstrdup(params, GFP_KERNEL);
|
||||
if (!tmp_options) {
|
||||
P9_DPRINTK(P9_DEBUG_ERROR,
|
||||
"failed to allocate copy of option string\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
options = tmp_options;
|
||||
|
||||
while ((p = strsep(&options, ",")) != NULL) {
|
||||
int token;
|
||||
@@ -760,7 +761,8 @@ static int parse_opts(char *params, struct p9_fd_opts *opts)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
kfree(options);
|
||||
|
||||
kfree(tmp_options);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+5
-4
@@ -166,7 +166,7 @@ static int parse_opts(char *params, struct p9_rdma_opts *opts)
|
||||
char *p;
|
||||
substring_t args[MAX_OPT_ARGS];
|
||||
int option;
|
||||
char *options;
|
||||
char *options, *tmp_options;
|
||||
int ret;
|
||||
|
||||
opts->port = P9_PORT;
|
||||
@@ -177,12 +177,13 @@ static int parse_opts(char *params, struct p9_rdma_opts *opts)
|
||||
if (!params)
|
||||
return 0;
|
||||
|
||||
options = kstrdup(params, GFP_KERNEL);
|
||||
if (!options) {
|
||||
tmp_options = kstrdup(params, GFP_KERNEL);
|
||||
if (!tmp_options) {
|
||||
P9_DPRINTK(P9_DEBUG_ERROR,
|
||||
"failed to allocate copy of option string\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
options = tmp_options;
|
||||
|
||||
while ((p = strsep(&options, ",")) != NULL) {
|
||||
int token;
|
||||
@@ -216,7 +217,7 @@ static int parse_opts(char *params, struct p9_rdma_opts *opts)
|
||||
}
|
||||
/* RQ must be at least as large as the SQ */
|
||||
opts->rq_depth = max(opts->rq_depth, opts->sq_depth);
|
||||
kfree(options);
|
||||
kfree(tmp_options);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user