Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 296416
b: refs/heads/master
c: 31efceb
h: refs/heads/master
v: v3
  • Loading branch information
Al Viro authored and Richard Weinberger committed Mar 24, 2012
1 parent 0b136a1 commit f8192d0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 29 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d8c215adbf3901aa7d00a0f17f08d77be689f838
refs/heads/master: 31efcebb7d7196adcee73027f513d7c0bf572b47
3 changes: 3 additions & 0 deletions trunk/arch/um/drivers/chan_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,9 @@ int parse_chan_pair(char *str, struct line *line, int device,
INIT_LIST_HEAD(chans);
}

if (!str)
return 0;

out = strchr(str, ',');
if (out != NULL) {
in = str;
Expand Down
54 changes: 26 additions & 28 deletions trunk/arch/um/drivers/line.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ void close_lines(struct line *lines, int nlines)
}

static int setup_one_line(struct line *lines, int n, char *init,
char **error_out)
const struct chan_opts *opts, char **error_out)
{
struct line *line = &lines[n];
int err = -EINVAL;
Expand All @@ -494,13 +494,28 @@ static int setup_one_line(struct line *lines, int n, char *init,
goto out;
}

if (!strcmp(init, "none"))
line->valid = 0;
else {
line->init_str = init;
if (!strcmp(init, "none")) {
if (line->valid) {
line->valid = 0;
kfree(line->init_str);
parse_chan_pair(NULL, line, n, opts, error_out);
err = 0;
}
} else {
char *new = kstrdup(init, GFP_KERNEL);
if (!new) {
*error_out = "Failed to allocate memory";
return -ENOMEM;
}
line->init_str = new;
line->valid = 1;
err = parse_chan_pair(new, line, n, opts, error_out);
if (err) {
line->init_str = NULL;
line->valid = 0;
kfree(new);
}
}
err = 0;
out:
mutex_unlock(&line->count_lock);
return err;
Expand Down Expand Up @@ -549,10 +564,8 @@ int line_setup(char **conf, unsigned int num, char **def,
int line_config(struct line *lines, unsigned int num, char *str,
const struct chan_opts *opts, char **error_out)
{
struct line *line;
char *new;
char *end;
int n, err;
int n;

if (*str == '=') {
*error_out = "Can't configure all devices from mconsole";
Expand All @@ -569,16 +582,7 @@ int line_config(struct line *lines, unsigned int num, char *str,
return -EINVAL;
}

new = kstrdup(end, GFP_KERNEL);
if (new == NULL) {
*error_out = "Failed to allocate memory";
return -ENOMEM;
}
err = setup_one_line(lines, n, new, error_out);
if (err)
return err;
line = &lines[n];
return parse_chan_pair(line->init_str, line, n, opts, error_out);
return setup_one_line(lines, n, end, opts, error_out);
}

int line_get_config(char *name, struct line *lines, unsigned int num, char *str,
Expand Down Expand Up @@ -633,7 +637,7 @@ int line_remove(struct line *lines, unsigned int num, int n, char **error_out)
*error_out = "Device number out of range";
return -EINVAL;
}
return setup_one_line(lines, n, "none", error_out);
return setup_one_line(lines, n, "none", NULL, error_out);
}

struct tty_driver *register_lines(struct line_driver *line_driver,
Expand Down Expand Up @@ -688,15 +692,9 @@ void lines_init(struct line *lines, int nlines, struct chan_opts *opts)
if (line->init_str == NULL)
continue;

line->init_str = kstrdup(line->init_str, GFP_KERNEL);
if (line->init_str == NULL)
printk(KERN_ERR "lines_init - kstrdup returned NULL\n");

if (parse_chan_pair(line->init_str, line, i, opts, &error)) {
printk(KERN_ERR "parse_chan_pair failed for "
if (setup_one_line(lines, i, line->init_str, opts, &error))
printk(KERN_ERR "setup_one_line failed for "
"device %d : %s\n", i, error);
line->valid = 0;
}
}
}

Expand Down

0 comments on commit f8192d0

Please sign in to comment.